当前位置:编程学习 > C#/ASP.NET >>

卡住了,请指教

enum GanderNum {Male,Famale}
    public class Person
    {
        private int age;
        public int Age
        {
            set
            {
                this.age = value; 
            }
            get
            {
                return this.age;
            }
        }
        public GanderNum Gander
        {
            set;
            get;
        }
        private int height;
        public int Height
        {
            set
            {
                this.height = value; 
            }
            get
            {
                return this.height;
            }
        }
        private string name;
        public string Name
        {
            set
            {
                this.name = value;
            }
            get
            {
                return this.name;
            }
        }
        private int weight;
        public int Weight
        {
            set
            {
                this.weight = value;
            }
            get
            {
                return this.weight;
            }
        }
        public Person(int i, GanderNum g, int j, string s, int l)
        {
            this.Age = i;
            this.Gander = g;
            this.Height = j;
            this.Name = s;
            this.Weight = l;
        }
        public void SayHello()
        {
            Console.WriteLine(" 我的年龄是{0},我的性别是{1}我的身高是{2}我的名字是{3}我的体重是{4}", Age, Gander, Height, Name, Weight);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {

            Person p1 = new Person(1, GanderNum.Famale, 10, "lily", 18);
            p1.SayHello();
            Console.ReadKey();
        }
    } --------------------编程问答-------------------- class Student
    {
        private Genders gender;
        public Genders Gender
        {
            get { return gender; }
            set { gender = value; }
        }
    }
Student stu = new Student();
stu.Gender = Genders.Male;
int i= (int)stu.Gender;
补充:.NET技术 ,  C#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,