[英]Nested class with static property access issue from outside c#
i have one main class and with in this main class i have another class A. class A has few static property and when i tried to access those static property from outside but getting error....not being possible 我有一个主类,并在这个主类我有另一个类A.类A有很少的静态属性,当我试图从外部访问这些静态属性但得到错误....不可能
public class EShip
{
class Credentials
{
private static string _accessKey = "aaa";
private static string _accessPwd = "xxx";
private static string _accountNumber = "2222";
public static string AccessKey
{
get { return _accessKey; }
}
public static string AccessPassword
{
get { return _accessPwd; }
}
public static string AccountNumber
{
get { return _accountNumber; }
}
}
public static Credentials Credential
{
{ get; }
}
}
i try to expose that inner class by a main class property and from outside i try to do like 我尝试通过主类属性公开内部类,并从外部尝试做
EShip.Credentials.AccessKey
EShip.Credentials.AccessPassword
it is not getting possible......suggest me good approach and why i am stuck. 这是不可能......建议我好方法,为什么我卡住了。 thnx. 日Thnx。
Class Credentials
is not public, therefore it's not accessible. 类Credentials
不公开,因此无法访问。 Change that and you're able to do: 改变你,你能做到:
String key = EShip.Credentials.AccessKey;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.