Tôi muốn tạo thuộc tính trong C# để đặt hoặc trả về một thành viên riêng lẻ của một mảng. Hiện nay, tôi có điều này:Thuộc tính trưng bày các phần tử mảng trong C#
private string[] myProperty;
public string MyProperty[int idx]
{
get
{
if (myProperty == null)
myProperty = new String[2];
return myProperty[idx];
}
set
{
myProperty[idx] = value;
}
}
Tuy nhiên, tôi nhận được lỗi biên dịch sau:
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.
http://www.codeproject.com/KB/cs/csharptips.aspx –