whq1982() :将该结构体设为public static Knight94(愚翁) : 用属性来实现 ================================== 帮你实现一下就明白了:class A { String name = B.yourStruct.Name; //调用咯 }class B { private static customStruct yourStruct;
public B() { yourStruct = new CustomStruct("kevin"); } }struct CustomStruct { private name; public Name { get { return this.name; } set { this.name = value; } }
public CustomStruct(string n) { this.Name = n; } }
吆!!!! B忘记用属性了 class B { private static customStruct yourStruct; public customStruct YourStruct { get { return this.yourStruct; } set { this.yourStruct = value; } } public B() { yourStruct = new CustomStruct("kevin"); } }
http://blog.csdn.net/knight94/archive/2006/06/04/772886.aspx
Knight94(愚翁) : 用属性来实现
==================================
帮你实现一下就明白了:class A
{
String name = B.yourStruct.Name; //调用咯
}class B
{
private static customStruct yourStruct;
public B() { yourStruct = new CustomStruct("kevin"); }
}struct CustomStruct
{
private name;
public Name
{
get { return this.name; }
set { this.name = value; }
}
public CustomStruct(string n) { this.Name = n; }
}
class B
{
private static customStruct yourStruct; public customStruct YourStruct
{
get { return this.yourStruct; }
set { this.yourStruct = value; }
} public B() { yourStruct = new CustomStruct("kevin"); }
}