日期:2014-05-18 浏览次数:20818 次
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace csharpOOP003 { class Program { static void Main(string[] args) { person ps1 = new person("michell",gender.女,20,160); ps1.showinfo(); //ps1.NAME = "nick"; //ps1.SEX = gender.男; //ps1.AGE = 27; //ps1.HEIGHT = 172; Console.WriteLine("大家好,我叫{0},性别{1},今年{2}岁,身高{3}厘米!", ps1.NAME, ps1.SEX, ps1.AGE,ps1.HEIGHT); Console.WriteLine("按任意键退出程序..."); Console.ReadKey(); } } public enum gender { 男,女}; class person { private string _name; private gender _sex; private int _age; private int _height; public string NAME { get; set; } public gender SEX { get; set; } public int AGE { get; set; } public int HEIGHT { get; set; } public person() { this._name = ""; this._sex = gender.男; this._age = 0; this._height = 0; } public person(string name, gender sex, int age, int height) { this._name = name; this._sex = sex; this._age = age; this._height = height; } public void showinfo() { Console.WriteLine("我叫{0},性别{1},今年{2}岁,身高{3}厘米!", this._name,this._sex,this._age,this._height); } } }