本帖最后由 李贤贤 于 2013-3-12 12:47 编辑
namespace 结构
{
enum Gender
{
男,
女
}
public struct Person {
public string name;
public int age;
public Gender sex;
}
class Program
{
static void Main(string[] args)
{
Person onePerson;
onePerson.name = "张三";
onePerson.age = 26;
onePerson.sex = Gender.男;
Person twePerson;
twePerson.name = "李四";
twePerson.age = 26;
twePerson.sex = Gender.男;
Console.WriteLine("{0}和{1}是好朋友",onePerson.name,twePerson.name);
Console.ReadLine();
}
}
}
错误原因:可访问性不一致:字段类型“结构.Gender”比字段“结构.Person.sex”的可访问性低
|