DLL 属性 不可设置
DLL Property no settable
为什么我无法设置 属性?
DLL 已导入,所有方法均可访问,但 URL 属性 不会显示,而且似乎也不存在
http://prntscr.com/6y2az8
Dll代码:
namespace Steap
{
public class SteapAPI
{
public static String URL
{
get;
set;
}
public static XmlReader r = XmlReader.Create("");
public int getSteamID64()
{
int ID = 0;
r.ReadToFollowing("steamID64");
ID = r.ReadContentAsInt();
return ID;
}
public string getSteamID()
{
string ID = String.Empty;
r.ReadToFollowing("steamID");
ID = r.ReadContentAsString();
return ID;
}
public string getName()
{
return getSteamID();
}
}
}
我还使用了 string 而不是 String,我需要 static 用于后面的语句
在您添加的图像中,您正试图像这样访问它:
SteapAPI sapi = new SteapAPI);
sapi.URL = // ... do something
您的 属性 是静态的,因此您应该从 class 而不是实例中调用它:
SteapAPI.URL = // ... do something
静态属性在 class 而不是实例上。使用
SteapAPI.URL
请记住,这意味着该值由 class 的所有实例共享。
如果它是静态的,那么你可以像
一样访问它
SteapAPI.URL
为什么我无法设置 属性? DLL 已导入,所有方法均可访问,但 URL 属性 不会显示,而且似乎也不存在 http://prntscr.com/6y2az8
Dll代码:
namespace Steap
{
public class SteapAPI
{
public static String URL
{
get;
set;
}
public static XmlReader r = XmlReader.Create("");
public int getSteamID64()
{
int ID = 0;
r.ReadToFollowing("steamID64");
ID = r.ReadContentAsInt();
return ID;
}
public string getSteamID()
{
string ID = String.Empty;
r.ReadToFollowing("steamID");
ID = r.ReadContentAsString();
return ID;
}
public string getName()
{
return getSteamID();
}
}
}
我还使用了 string 而不是 String,我需要 static 用于后面的语句
在您添加的图像中,您正试图像这样访问它:
SteapAPI sapi = new SteapAPI);
sapi.URL = // ... do something
您的 属性 是静态的,因此您应该从 class 而不是实例中调用它:
SteapAPI.URL = // ... do something
静态属性在 class 而不是实例上。使用
SteapAPI.URL
请记住,这意味着该值由 class 的所有实例共享。
如果它是静态的,那么你可以像
一样访问它SteapAPI.URL