问题描述
有没有更好的方法来填充数组然后这个
a是一个自动生成的值,总是不同的。
它意味着循环直到数组充满了值,这会有效吗?
int i = 0;
while(array [array.Length-1] == null)
{
array [i] = a;
i ++;
}
is there a better way to fill an array then this
a is a auto generated value, always different.
its meant to loop through until the array is full of values, will this work?
int i=0;
while(array[array.Length-1] == null)
{
array[i] = a;
i++;
}
推荐答案
嗯,这会更好:
for(int i = 0; i< array.Length; i ++)
{
array [i] = a;
}
我不认为框架中有任何东西可以填充数组
虽然。
-
Jon Skeet - < sk *** @ pobox.com>
如果回复该群组,请不要给我发邮件
Well, this would be nicer:
for (int i=0; i < array.Length; i++)
{
array[i] = a;
}
I don''t think there''s anything in the framework to fill an array
though.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
这篇关于使用数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!