using System; namespace ConsoleApp3 { struct WuGong { public string Name; public int Attack; } class Program { static void Main(string[] args) { WuGong[] wg = new WuGong[3]; wg[0].Name = "辟邪剑法"; wg[0].Attack = 500; wg[1].Name = "降龙十八掌"; wg[1].Attack = 600; wg[2].Name = "暗然消魂掌"; wg[2].Attack = 400; Console.WriteLine(wg[1].Attack); int[,] a = { {1,2,3 },{4,5,6 },{7,8,9 } }; // 1 2 3 // 4 5 6 // 7 8 9 Console.WriteLine(a[0,2]);//3 数组是从0开始计数 for (int i = 0; i < a.GetLength(0); i++)//取行的长度 { for (int i1 = 0; i1 < a.GetLength(1); i1++)//取列的长度 { Console.WriteLine(a[i,i1]); } } foreach (var item in a) { Console.WriteLine(item);//使用foreach直接遍历 } } } }