using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Person p1 = new Person();
p1.Name = "孙权";
p1.Age = 18;
p1.Gender ='男';
Console.WriteLine("他叫{0}。今年{1}岁,性别{2}",p1.Name,p1.Age,p1.Gender);
Console.ReadKey();
}
}
class Person
{
private string name;
private int age;
private char gender;
public string Name
{
set { name = value; }
get { return name; }
}
public int Age
{
set { age = value; }
get { return age; }
}
public char Gender
{
set { gender = value; }
get { return gender; }
}
}
}
C#的面向对象初级之属性
猜你喜欢
转载自blog.csdn.net/makabaka12138/article/details/127435195
今日推荐
周排行