这是一个动态创建单选按钮组的代码
this.RadioButtonList1.Items.Clear();//清除所有单选按钮的选项
colors.GetLength(0)//这我没见过,应该跟colors.Length差不多吧
this.RadioButtonList1.Items.Add(colors[i]);//把数组中的值都添加到单选按钮选项里面以后遇见问题多看看msdn
查查帮助
this.RadioButtonList1.Items.Clear();//清除所有单选按钮的选项
colors.GetLength(0)//这我没见过,应该跟colors.Length差不多吧
this.RadioButtonList1.Items.Add(colors[i]);//把数组中的值都添加到单选按钮选项里面以后遇见问题多看看msdn
查查帮助
把里面的项清空。
string[,] 二维二维的时候数据可以看成是个表
1,2,3
4,5,6
以上数据可以实例化成 new string[2,3];colors.GetLength(0); 取出的是2
colors.GetLength(1); 取出的是3
那么你用个循环
for (i = 0; i <a.getlength(0) ; i++)
{
for (j = 0; j <a.getlength(1); j++)
{
Console.WriteLine("a[{0}{1}]={2}",i,j,a[i,j]);
}
}
colors.GetLength(0)的意思就是说你输出第一维的数
colors.GetLength(1)的意思就是说你输出第二维的数
总的来说就是你要是是二维数组,那么你就只能是colors.GetLength(0)和colors.GetLength(1),这是必须的,要是三维的,那么在来一个for循环,里面再写一个colors.GetLength(2),就是第三维的输出
colors是一维数组。
数组可以是多维滴。拿二维数组给你举个例子。
string[,]arr=new string[5,6]//数组必须标示每一维的长度
for (i = 0; i <a.getlength(0) ; i++)
{
for (j = 0; j <a.getlength(1); j++)
{
////////////
}
}a.getlength(0)就相当于a.Length
不同的是后面跟的数字就代表不同的维
下面的a是arr的简写