zoukankan      html  css  js  c++  java
  • C# Array.CreateInstance创建二维数组及如何遍历二维数组



    1 static void Main(string[] args) 2 { 3 //创建二维数组 4 int[] lengths = {2,3}; 5 int[] lowerBounds = { 1, 10 }; 6 Array arr1 = Array.CreateInstance(typeof(string),lengths,lowerBounds); 7 //给数组赋值 8 arr1.SetValue("", 1, 10); 9 arr1.SetValue("", 1, 11); 10 arr1.SetValue("", 1, 12); 11 arr1.SetValue("", 2, 10); 12 arr1.SetValue("", 2, 11); 13 arr1.SetValue("", 2, 12); 14 //遍历数组 15 System.Collections.IEnumerator arr2 = arr1.GetEnumerator(); 16 int i = 0; 17 int cols = arr1.GetLength(arr1.Rank - 1); 18 while(arr2.MoveNext()){ 19 if (i < cols) 20 { 21 i++; 22 } 23 else { 24 Console.WriteLine(); 25 i = 1; 26 } 27 Console.Write(" {0}",arr2.Current); 28 } 29 Console.WriteLine(); 30 Console.ReadKey(); 31 }

    站在巨人的肩膀上真的会看的更远更清晰!

                               -----用志不分,乃凝于神

  • 相关阅读:
    Eclipse中项目去除Js验证
    Web安全扫描工具
    Oracle-定时任务
    About_Return
    About_php_封装函数
    About_PHP_函数
    About_PHP_验证码的生成
    About_PHP_文件的上传
    About_MySQL Select--来自copy_03
    About_AJAX_03
  • 原文地址:https://www.cnblogs.com/xiong950413/p/9773025.html
Copyright © 2011-2022 走看看