#region 索引器
public class IndexClass
{
private int[] arr = new int[100];
public int this[int index]
{
get
{
if (index < 0 || index >= 100)
{
return 0;
}
else
{
return arr[index];
}
}
set
{
if (!(index < 0 || index >= 100))
{
arr[index] = value;
}
}
}
}
#endregion
可空类型可以表示其基础值类型正常范围内的值,再加上一个 null 值
int? num = null;