类属性
有两种途径揭示类的命名属性(1)域成员*(2)属性
实现属性存储标志
using System;
public class House
{
private int m_nSqFeet;
Public int SquareFeet
{
get{ return m_nSqFeet; }
set{ m_nSqFeet=value; }
}
}
class TestApp
{
public static void Main()
{
House myHouse= new House();
myHouse.SquareFeet=250;
Console.WriteLine(myHouse.SquareFeet);
}
}
索引
基本语法 :
属性 修饰符 声明 {声明内容}
public string this[int nIndex]
{
get{....}
set{..........}
}