这是我对ArrayList数据进行排序的代码
ArrayList myList = new ArrayList();
int firstNumber=int.Parse(txt1.Text);
int secondNumber = int.Parse(txt2.Text);
for (int i = firstNumber; i <= secondNumber; i++) {
if (i%2==0) {
myList.Add(i);
lstbox1.Items.Add(myList);
}
}
但是当我运行这个程序时,就会发生这种情况:
Xaml Code
<Grid>
<TextBox x:Name="txt1" HorizontalAlignment="Left" Height="23" Margin="10,15,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
<TextBox x:Name="txt2" HorizontalAlignment="Left" Height="23" Margin="10,58,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
<Button x:Name="btnOk" Content="Button" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="150,15,0,0" Click="btnOk_Click"/>
<Label x:Name="lbl1" Content="Label" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="150,55,0,0"/>
<ListBox x:Name="lstbox1" HorizontalAlignment="Left" Height="100" VerticalAlignment="Top" Width="100" Margin="10,102,0,0"/>
</Grid>