扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
000: // Arrays\arrays.cs 001: using System; 002: class DeclareArraysSample 003: { 004: public static void Main() 005: { 006: // Single-dimensional array 007: int[] numbers = new int[5]; 008: 009: // Multidimensional array 010: string[,] names = new string[5,4]; 011: 012: // Array-of-arrays (jagged array) 013: byte[][] scores = new byte[5][]; 014: 015: // Create the jagged array 016: for (int i = 0; i < scores.Length; i++) 017: { 018: scores[i] = new byte[i+3]; 019: } 020: 021: // Print length of each row 022: for (int i = 0; i < scores.Length; i++) 023: { 024: Console.WriteLine("Length of row {0} is {1}", i, scores[i].Length); 025: } 026: } 027: } |
Length of row 0 is 3 Length of row 1 is 4 Length of row 2 is 5 Length of row 3 is 6 Length of row 4 is 7 |
int[] numbers = new int[5] {1, 2, 3, 4, 5}; string[] names = new string[3] {"Matt", "Joanne", "Robert"}; |
int[] numbers = new int[] {1, 2, 3, 4, 5}; string[] names = new string[] {"Matt", "Joanne", "Robert"}; |
int[] numbers = {1, 2, 3, 4, 5}; string[] names = {"Matt", "Joanne", "Robert"}; |
int[] numbers = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; numbers[4] = 5; |
int[,] numbers = { {1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10} }; numbers[1, 1] = 5; |
int[] numbers = {1, 2, 3, 4, 5}; int LengthOfNumbers = numbers.Length; |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者