我如何quicky填充一个特定值的数组? [英] How do I quicky fill an array with a specific value?
本文介绍了我如何quicky填充一个特定值的数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Array.Clear()填充的默认值(整数零)的阵列,我想利用例如它-1填补。
Array.Clear() fills the arrays with the default value (zero for integers), I would like to fill it using -1 for example.
感谢。
推荐答案
另一种方法是:
int[] arr = Enumerable.Repeat(-1, 10).ToArray();
Console.WriteLine(string.Join(",",arr));
这篇关于我如何quicky填充一个特定值的数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文