09002 构造函数源代码 – 恵玩科技

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace day9
{
    class Structure
    {
        public Structure()
        {

        }
        public Structure(string name,int age,char gender,int english,int chinese,int math)
        {
            Name = name;
            Age = age;
            Gender = gender;
            English = english;
            Chinese = chinese;
            Math = math;
        }
        private string name;
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        private int age;
        public int Age
        {
            get { return age; }
            set { age = value; }
        }
        private char gender;
        public char Gender
        {
            get { return gender; }
            set { gender = value; }
        }
        private int english;
        public int English
        {
            get { return english; }
            set { english = value; }
        }
        private int chinese;
        public int Chinese
        {
            get { return chinese; }
            set { chinese = value; }

        }
        private int math;
        public int Math
        {
            get { return math; }
            set { math = value; }
        }
        public void Say()
        {
            Console.WriteLine("我的名字是{0},我的年龄是{1},我的性别是{2},我的英语成绩是{3},我的语文成绩是{4},我的数学成绩是{5}",Name,Age,Gender,English,Chinese,Math);
        }
    }
}

 

打赏作者