C#Set/Get方法

来源:互联网 发布:软件测试规范标准 编辑:程序博客网 时间:2024/05/22 10:25
<pre name="code" class="csharp"><span style="font-size:14px;">// C#中类的 set get方法public class AAA{    private string m_name;    public AAA() { }    public string Name    {        get { return m_name; }        set { m_name = value; }    }}</span>

<span style="font-size:14px;">  private void Force()    {        AAA aa = new AAA(); // 实例化类对象        aa.Name = "qqqqq";  // Set方法        print(aa.Name);     // Get 方法    }</span>


                                             
0 0