专注于互联网--专注于架构

最新标签
网站地图
文章索引
Rss订阅
示例    下面是一个完整的 C# 程序,它声明并实例化上面所讨论的数组。    // arrays.cs    using System;    class DeclareArraysSample    {      public static void Main()      {         // Single-dimensional array         int[] numbers = new int[5];         // Multidimensional array         string[,] names = new st [阅读全文] [PDF]
 本教程描述数组并展示它们在 C# 中的工作方式。 教程    本教程分为下述几节:     1.数组概述     2.声明数组     3.初始化数组     4.访问数组成员     5.数组是对象     6.对数组使用 foreach数组概述    C# 数组从零开始建立索引,即数组索引从零开始。C# 中数组的工作方式与在大多数其他流行语言中的工作方式类似。但还有一些差异应引起注意。     声明数组时,方括号 ([]) 必须跟在类型后面,而不是标识符后面。在 C# 中,将方括号放在标识符后是不合法的语法。    int[] table; // n [阅读全文] [PDF]
多维数组     int[,] numbers = new int[3, 2] { {1, 2}, {3, 4}, {5, 6} };     string[,] siblings = new string[2, 2] { {\"Mike\",\"Amy\"}, {\"Mary\",\"Albert\"} };    可省略数组的大小,如下所示:     int[,] numbers = new int[,] { {1, 2}, {3, 4}, {5, 6} };     string[,] siblings = new string[,] { {\"Mi [阅读全文] [PDF]
方法一:string[] str = new string[2]; str[0] = \"a\"; str[1] = \"b\"; Response.Write(str[0].ToString()); Response.Write(str[1].ToString());方法二: string[] str = new string[] { \"x\", \"xx\", \"xxx\" }; for (int i = 0; i < str.Length; i++) { Response.Write(str[i].ToString()); Response [阅读全文] [PDF]
1 共4条 分1页