vb.net转c#

wall86144 2004-11-30 10:17:15
dim aa() as double
public property AA(byval i as inter) as double
{
get
return aa(i)
end get
set(byval value as double)
aa(i)=value
end set
}
怎么转换成c# 参数i怎么传进去
...全文
101 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
wall86144 2004-11-30
  • 打赏
  • 举报
回复
up
melonlee 2004-11-30
  • 打赏
  • 举报
回复
学习~
wall86144 2004-11-30
  • 打赏
  • 举报
回复
我要在外面可以显示的是this.AA[1]
这个样式的
wall86144 2004-11-30
  • 打赏
  • 举报
回复
hbxtlhx(下着春雨的天) :
假如我里面有多个这样的属性
都可以这样写吗?
北京的雾霾天 2004-11-30
  • 打赏
  • 举报
回复
我改了一下,大致上修改成C#也就是如下的样子:
private double[] aa;

public double this[int index]
{
get
{
return aa[index];
}
set
{
aa[index] = value
}
}
北京的雾霾天 2004-11-30
  • 打赏
  • 举报
回复
这里有一个例子,你参考一下:

using System;
class IndexerClass
{
private int [] myArray = new int[100];
public int this [int index] // Indexer declaration
{
get
{
// Check the index limits.
if (index < 0 || index >= 100)
return 0;
else
return myArray[index];
}
set
{
if (!(index < 0 || index >= 100))
myArray[index] = value;
}
}
}
北京的雾霾天 2004-11-30
  • 打赏
  • 举报
回复
你的是一个索引的定义,在C#的MSDN里找一下索引的用法就OK了,索引是可以传一个参数进去的.
wall86144 2004-11-30
  • 打赏
  • 举报
回复
up

110,532

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧