我有一个这样的设置类:
public class Settings
{
string resourcePath;
public string ResourcePath {
get {
return resourcePath + "/";
}
set {
resourcePath = value;
}
}
string texturePath;
public string TexturePath {
get {
string a = resourcePath + "/"; // This is just some debug stuff I did trying to find out wtf is going on
string b = texturePath + "/";
return a + b; // Breakpointing here shows that it is "Content/Textures/"
}
set {
texturePath = value;
}
}
public Settings ()
{
resourcePath = "Content";
texturePath = "Textures";
}
public static Settings CurrentSettings = new Settings();
}
然后我尝试从中获取 TexturePath,如下所示:
string path = Settings.CurrentSettings.TexturePath + file;
该属性返回的字符串是"Content//Content/Textures//"
我在这里想念什么?为什么这样做?据我所知,它应该返回Content/Textures/