我正在寻找在 C# 中执行此操作。
public struct Structure1
{ string string1 ; //Can be set dynamically
public string[] stringArr; //Needs to be set dynamically
}
一般来说,如果需要,应该如何动态初始化一个数组?简而言之,我试图在 C# 中实现这一点:
int[] array;
for (int i=0; i < 10; i++)
array[i] = i;
另一个例子:
string[] array1;
for (int i=0; i < DynamicValue; i++)
array1[i] = "SomeValue";