used the variable size of array at runtime
I want to create a dynamic array in C# at runtime then use this variable array values:
int z = 0;
int k=0;
int[] err11;
if (y == 1)
{
while(z < laddrslt)
{
if (addRs开发者_运维知识库lt[z].Error < 0)
{
err[]=new int[k];
err11[k] = item[z].HandleClient ;
k++;
}
z++;
}
}
if (err11.Length < addRslt.Length)
{
//code
}
You can't resize an array. Use a list instead:
List<int> err11 = new List<int>();
if (y == 1) {
for (int z = 0, z < addRslt.Length, z++) {
if (addRslt[z].Error < 0) {
err11.Add(item[z].HandleClient);
}
}
}
if (err11.Count < addRslt.Length) {
//code
}
精彩评论