《零基础学C#》第七章-实例01:定义员工类——练习1

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wtxhai/article/details/88735620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Example701_01
{
    class Employee
    {
        public string name;     //定义名字
        public int age;  //定义年龄
    }
    class Program
    {
        static void Main(string[] args)
        {
            Employee e = new Employee();   //创建员工的类
            Console.Write("请输入您的名字:");       
            e.name = Console.ReadLine();                //接收输入的名称
            Console.Write("请输入您的年龄:");
            e.age = Convert.ToInt32(Console.ReadLine());    //接收输入的年龄
            Console.WriteLine("您的姓名是:{0},您的年龄是:{1}",e.name,e.age);   //输出接收到的信息
            Console.ReadLine();
        }
    }
}

猜你喜欢

转载自blog.csdn.net/wtxhai/article/details/88735620