C# 这串代码 我想定义一个方法做输入二维数组,但是主函数我不懂如何调用这个输入的二维数组

并且这里有一个问题,

大神们可以教教我如何调用方法 如何正确定义吗?

using System;using System.Collections.Generic;using System.Linq;using System.Text;
namespace 数组_结构体{ class Program {
public static int input (int [,] a ) { int i=0; int j=0; Console.WriteLine( "Please input the hang"); int n = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Please input the lie "); int m = Convert.ToInt32(Console.ReadLine()); int [,] b = new int [n,m]; for ( i=0;i<n;i++) { for ( j=0; j < m; j++) { Console.WriteLine("请输入第{0}行,第{1}列的元素", i, j); b[i, j] = Convert.ToInt32(Console.ReadLine()); } } return b[i,j]; }

static void Main(string[] args) { int a=0 ; int b=0; int [,]j= new int [a,b]; int l1; ; l1= input(j ); } }}

完全不知道你想 干什么。。

这是啥代码。。。

===============

public static int[,] input()
        {
            
            Console.WriteLine("Please input the hang");
            int n = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Please input the lie ");
            int m = Convert.ToInt32(Console.ReadLine());
            int[,] b = new int[n, m];
            for (int i = 0; i <n; i++)
            {
                for (int j = 0; j <m; j++)
                {
                    Console.WriteLine("请输入第{0}行,第{1}列的元素", i, j);
                    b[i, j] = Convert.ToInt32(Console.ReadLine());
                }

            }
            return b;

        }

        static void Main(string[] args)
        {

            
            int[,] l1;
            l1 = input();
        }

追问

。。。通过方法实现 二维数组的输入 NM 分别定义几行几列

追答

已经改好啦。。

温馨提示:答案为网友推荐,仅供参考