using System;
using System.Collections.Generic;
using System.Text;namespace 构造函数
{
class Person
{ enum GEnderSex{male,famale}
private GEnderSex gender;
public int Age{get;
set;}
public int Weight{get;
set;}
private GEnderSex Sex
{
get{return gender;}
}
public Person(int age,int weight,GEnderSex sex){this.Age=age;
this.Weight=weight;
this.Sex = GEnderSex.sex;
}
}
class programe{ static void Main(string[] args)
{Person p1=new person(1,8,GEnderSex.male);
}
}
}
错误:错误 1 可访问性不一致: 参数类型“构造函数.Person.GEnderSex”比方法“构造函数.Person.Person(int, int, 构造函数.Person.GEnderSex)”的可访问性低 C:\Documents and Settings\Administrator\Local Settings\Application Data\Temporary Projects\构造函数\Program.cs 20 9 构造函数
using System.Collections.Generic;
using System.Text;namespace 构造函数
{
class Person
{ enum GEnderSex{male,famale}
private GEnderSex gender;
public int Age{get;
set;}
public int Weight{get;
set;}
private GEnderSex Sex
{
get{return gender;}
}
public Person(int age,int weight,GEnderSex sex){this.Age=age;
this.Weight=weight;
this.Sex = GEnderSex.sex;
}
}
class programe{ static void Main(string[] args)
{Person p1=new person(1,8,GEnderSex.male);
}
}
}
错误:错误 1 可访问性不一致: 参数类型“构造函数.Person.GEnderSex”比方法“构造函数.Person.Person(int, int, 构造函数.Person.GEnderSex)”的可访问性低 C:\Documents and Settings\Administrator\Local Settings\Application Data\Temporary Projects\构造函数\Program.cs 20 9 构造函数
{
get{return gender;}}
改成public
里面加set属性。。
public GEnderSex Sex
using System.Collections.Generic;
using System.Text;namespace 构造函数
{ enum GEnderSex{male,famale}
class Person
{
private GEnderSex gender;public int Age
{get;
set;}
public int Weight{get;
set;}
private GEnderSex Sex
{
get{return gender;}}
public Person(int age,int weight,GEnderSex sex){this.Age=age;
this.Weight=weight;
this.Sex = GEnderSex.sex;
}
}
class programe{static void Main(string[] args)
{
Person p1=new person(1,8,GEnderSex.male);
}
}
}