这是索引器的语法
get
{
return a[index];
} 返回a[i]值set
{
if(index>0&&index<100)
a[index] = value;
}
如果i大于0并且小于100,那么把值赋进去。
get
{
return a[index];
} 返回a[i]值set
{
if(index>0&&index<100)
a[index] = value;
}
如果i大于0并且小于100,那么把值赋进去。
解决方案 »
- 关于form窗体跳转及关闭的问题,求高手
- 如何在背景图上使用gdi+显示文字?
- 还是关于mail
- 最后30请帮忙解决一个代码问题
- $$$ public event MyDelegate OnOccurUseDelegate; 这行的event有什么用?
- 在线图像编辑器
- c# 操作 EXCEL Range.AutoFill() 出现 Range Class AutoFill方法失败
- 求助!!如何把datagridview 内的数据 推送到 report
- 求助:datagrid 根据查询动态生成表头
- 大家帮帮忙,用C#怎样才能把一个文本文件导成数据库。
- 急求 C#程序连接数据库的问题
- C# Timer的疑问
==
索引器,可以对一个对象象数组一样使用下标如果CSchedule 换成int呢?那应该如何理解啊?谢谢了!
==
不可以
public class CA
{
CSchedule[] a=new CSchedule[99]
public CSchedule this[int index]
{
get
{
return a[index];
}
set
{
if(index> 0&&index <100)
a[index] = value;
}
}
}CA A=new CA();
A[1]=new CSchedule();
CSchedule C=A[1];