Person
Posted 沫涵灵钧
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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的主要内容,如果未能解决你的问题,请参考以下文章