```csharp
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 学习类_对象_字段_属性_方法_构造函数_析构函数
{
**class Program**
{
static void Main(string[] args)
{
Person p = new Person("liu",20,"女");
p.Introduce();
Person p2 = new Person("zhang", 19, "男");
p2.Introduce();
Person p3 = new Person("wang", 16);
p3.Introduce();
p.Ip();
Person.Mangement();
Console.ReadKey();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 学习类_对象_字段_属性_方法_构造函数_析构函数
{
**public static class People**
{
private static string _Name;
public static string Name
{
get { return _Name; }
set { _Name = value; }
}
}
}
List item
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 学习类_对象_字段_属性_方法_构造函数_析构函数
{
public class Person
{
~Person()
{
}
public Person(string Name,int Age,string Sex)
{
this.Name = Name;
this.Age = Age;
this.Sex = Sex;
}
public Person(string Name,int Age):this(Name,Age," ")
{
}
private string _Name;
public string Name
{
get {
if(_Name!="zhang")
{
return "zhang";
}
return _Name; }
set{ _Name = value; }
}
private int _Age;
public int Age
{
get { return _Age; }
set {
if(value!=18)
{
value = 18;
}
_Age = value; }
}
private string _Sex;
public string Sex
{
get { return _Sex;}
set { _Sex = value; }
}
public void Introduce()
{
Console.WriteLine("我是{0},今年{1}岁了,是个{2}生", this.Name,this. Age,this. Sex);
}
public static void Mangement()
{
Console.WriteLine("我是一个静态方法,只有类名才能调用我");
}
public void Ip()
{
Console.WriteLine("我是一个非静态方法,只有对象名才能调用我");
}
}
}