using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace person
{
class Person
{
private string myName = "N/A";
private int myAge = 20;
public string Name
{
get
{
return myName;
}
set
{
myName = value;
}
}
public int Age
{
get
{
return myAge;
}
set
{
myAge = value;
}
}
public override string ToString()
{
return "Name=" + Name + ",Age=" + Age;
}
static void Main(string[] args)
{
Console.WriteLine("Simple properties");
Person person = new Person();
Console.WriteLine("Personal detail-{0}", person);
person.Name = "Joe";
person.Age = 88;
Console.WriteLine("New personal detail-{0}",person);
person.Age += 1;
Console.WriteLine("New second personal detail-{0}", person);
Console.ReadLine();
}
}
}
类的应用
最新推荐文章于 2021-12-26 12:27:42 发布