1
我试图产生随机int
数字,一旦我生成它们我想将它们存储在listBox
中,之后将它们排序在第二个listBox
之后。的代码,我有:创建随机数,将它们存储在数组中,并将它们排序在两个列表框中c#
int Min = 0;
int Max = 6;
// this declares an integer array with 5 elements
// and initializes all of them to their default value
// which is zero
int[] test2 = new int[6];
Random randNum = new Random();
for (int i = 1; i < test2.Length; i++)
{
test2[i] = randNum.Next(Min, Max);
}
arrayListbox.ItemsSource = test2;
Array.Sort(test2);
foreach (int value in test2)
{
arrayListboxOrder.ItemsSource = test2;
}
好了,出了什么问题,您有什么问题? – Lloyd
以及“完全多余和不必要的评论奖”的奖项是:“这声明了一个包含5个元素的整数数组,并将它们全部初始化为其默认值为零”。此外,它得到了错误:它有6个元素,而不是5 –
我注意到评论也是错误的... –