C#基礎 數組的認識、學習、與使用

博主近期要發佈一些關於c#基礎的內容 比較適用於初學c#的同學,希望對大家有幫助
//數組:應用數據類型的其中一種;
//概念:存儲一組具有相同類型的數據結構
//數據類型 中括號 數組名=賦值(花括號括起來 ,裏面放值,逗號隔開多個值)
int[] arr = { 19, 180, 120 };//索引,標記
Console.WriteLine(arr[0]);
//動態初始化
int[] arr1 = new int[3];
//賦值arr1[0] = 18;
// string[] names = { “張三”, “李四”, “王五”, “趙六” };
遍歷素組
//for (int i = 0; i < names.Length; i++)
//{
// Console.WriteLine(names[i]);
//}
//int indsx=0;
//while (true)
//{
// Console.WriteLine(names[indsx]);
// indsx++;
// if (indsx>3)
// {
// break;
// }
//}
數組排序
// int[] arr2 = { 15, 465, 5665, 1, 584, 23, 75 };
// for (int i = 0; i

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章