• c# 动态数组-----“动态”数组


    其实在大多数工作中我们能通过前处理来确定我们的数组有多大,这样我们就可以声明相应大小的数组了。我感觉这种“动态”数组就够我用了。比如我要处理excel中数据,数据有m行*n列,这样我就可以通过读取excel来确定m和n的大小,然后再声明m行n列的二维数组,这样就可以处理了啊。

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Text;
     5 using System.Threading.Tasks;
     6 
     7 namespace ConsoleApplication1array
     8 {
     9     class Program
    10     {
    11         static void Main(string[] args)
    12         {
    13             //Random r = new Random();
    14             Console.WriteLine("请输入二维数组的行数:");
    15             int i = int.Parse(Console.ReadLine()); //3; //r.Next() % 10 + 10;
    16             Console.WriteLine("请输入二维数组的列数:");
    17             int m = int.Parse(Console.ReadLine ());//4;
    18             int[,] array1 = new int[i,m];
    19             for (int fi = 0; fi < i;fi++ )
    20             {
    21                 for (int fj = 0; fj < m; fj++)
    22                 {
    23                     array1[fi, fj] = fi + fj;
    24                     Console.Write("{0}	 ",array1[fi, fj]);
    25                 }
    26                 Console.WriteLine();
    27 
    28             }
    29             //foreach (int  arr in array1)
    30             //{
    31                 
    32             //    Console.WriteLine(arr);
    33             //    Console.WriteLine();
    34             //}
    35             //for (int j = 0; j < i; j++)
    36             //{
    37             //    array1[j] = j;//r.Next(0,10);
    38             //    Console.WriteLine(array1[j]);
    39             //    Console.WriteLine();
    40             //}
    41             Console.ReadKey();
    42         }
    43     }
    44 }
    c#“动态数组”

     

  • 相关阅读:
    python调用WebService遇到的问题'Document' object has no attribute 'set'
    jquery AJAX 拦截器 success error
    js 钩子(hook)
    js 继承
    js Object的复制
    js关于 indexOf
    js重排序,笔记
    js类型检测,笔记
    jquery源码的阅读理解
    Windows IPC 连接详解(转)
  • 原文地址:https://www.cnblogs.com/zhubinglong/p/8120587.html
Copyright © 2020-2023  润新知