本帖最后由 袁振龙 于 2013-4-15 16:53 编辑
namespace 结构
{
enum gender
{
男,女
}
public struct Person
{
public string name;
public gender xingbie;
public int nianling;
}
class Program
{
static void Main(string[] args)
{
Person ren;
ren.name = "李四";
ren.nianling = 18;
ren.xingbie = gender.男;
Console.WriteLine("姓名是{0},性别是{1},年龄是{2}",ren.name,ren.xingbie,ren.nianling);
Person xue;
xue.name = "小伟";
xue.nianling = 22;
xue.xingbie = gender.女;
Console.WriteLine("姓名是{0},性别是{1},年龄是{2}", xue.name, xue.xingbie, xue.nianling);
Console.ReadKey();
}
}
}
提示错误是:访问性不一致“结构gender"比字段”结构person.xingbie"的可访问性低!什么意思! |