首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

struct中成员是struct对象的有关问题

2011-12-15 
struct中成员是struct对象的问题比如structA{intx1Bb}structB{intx2}Aaa.b.x22是否可以这样?AanewA

struct中成员是struct对象的问题
比如
struct   A{
int   x1;
B   b;
}

struct   B{
int   x2;
}

A   a;
a.b.x2=2;
是否可以这样?

A   a=new   A();时
b中的成员是否也被初始?



[解决办法]
第一问,必须public声明,如下:

struct A
{
int x1;
public B b;
}

struct B
{
public int x2;
}

热点排行