【发布时间】:2010-11-08 22:27:02
【问题描述】:
我有一个数组,它确实是一个函数,但是我想将它用作一个数组。我知道我可以写这些
int var { get{return v2;} }
public int this[int v] { get { return realArray[v]; }
但是我如何实现一个像数组一样的函数呢?我想做类似的事情
public int pal[int i] { get { return i*2; } }
但是会出现编译错误
error CS0650: Bad array declarator: To declare a managed array the rank specifier precedes the variable's identifier. To declare a fixed size buffer field, use the fixed keyword before the field type.
error CS0270: Array size cannot be specified in a variable declaration (try initializing with a 'new' expression)
【问题讨论】:
标签: c# arrays properties