using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace LeiheDuixiang
{
/// <summary>
/// 小朋友
/// </summary>
class Child
{
private string name; //字段
private string sex = "男";
private int age;
/// <summary>
/// 完成字段的对外访问接口
/// 属性,属性的名字首字母应该大写
/// </summary>
public string Name
{
get { return name; }//读访问器,返回字段的值
set { name = value; } //写访问器,给字段赋值
}
public string Sex
{
get { return sex; } //只读
}
public int Age
{
get { return age; }
set{ age = value; }
}
//有参的构造方法
public Child(string name, string sex, int age)
{
Name = name;
Age = age;
this.sex = sex; //this 当前对象,可以访问当前对象的对象,属性,方法