c# 数组的一些方法
定义数组方法一:string[] myarray = new string[5];
myarray[0] = "aaa";
myarray[1] = "sss";
myarray[2] = "ddd";
myarray[3] = "fff";
myarray[4] = "qqq";
定义数组方法二:Array myarr = Array.CreateInstance(GetType(string),5);
myarr.SetValue("aaa", 0);
myarr.SetValue("sss", 1);
myarr.SetValue("ddd", 2);
myarr.SetValue("eee", 3);
myarr.SetValue("rrr", 4);
定义数组方法三:string[] str = new string[6];
{ "aaa","sss","ddd","fff","sss" ,"fff"};
---------------------------------------------------------------------------------------------------------
show.Text = str.GetValue(4).ToString() // 得到数组中某个值
---------------------------------------------------------------------------------------------------------
找数组中某个值第一次出现的的位置: int i=Array.IndexOf(str,"ddd");
找数组中某个值最后一次出现的的位置: int i=Array.LastIndexOf(str, "ddd");
---------------------------------------------------------------------------------------------------------
Array.Reverse(str); //将数组翻转
Array.Sort(str); //将数组排序 按字母顺序 str都为数组名字
---------------------------------------------------------------------------------------------------------
foreach (string strings in str) 用foreach
{
mydropdownlist.Items.Add(strings); //把数组的每个值付给空间dropdownlist
}
---------------------------------------------------------------------------------------------------------
mydropdownlist.DataSource = str ;
mydropdownlist.DataBind(); //数据绑定