首页 > 代码库 > Person
Person
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PersonDemo2
{
/// <summary>
/// 性别
/// </summary>
public enum Gender
{
Female,Man
}
public class Person
{
#region
protected string name;
private Gender gender;
private string hobby;
protected int age;
#endregion
public Person()
{
}
public string Name
{
get { return name; }
set { name = value; }
}
public Gender Gender
{
get { return gender; }
set { gender = value; }
}
public string Hobby
{
get { return hobby; }
set { hobby = value; }
}
public virtual void Speak(string msg)
{
Console.WriteLine(name+"说"+msg);
}
public void ShowInfo()
{
Console.WriteLine("{0} {1} {2} {3}",name,gender,hobby,age);
}
public virtual void Study()
{
Console.WriteLine("so bad!");
}
}
}
Person