c#学习:c#下类的创建与类的调用

94 阅读1分钟

ctrl+shift+a新建一个类

static void Main(string[] args)
        {
            new1 people1;
            people1 = new new1();//初始化
            people1.name = "wang";
            Console.WriteLine(people1.name);
            people1.show();
            Console.ReadKey();
        }
class new1
    {
        public string name;
        public string address;
        public string age;
        public string buyTime;
        public void show()
        {
            Console.WriteLine("名字:" + name);
            Console.WriteLine("地址:" + address);
            Console.WriteLine("年龄:" + age);
            Console.WriteLine("购买时间:" + buyTime);
        }
    }