C# 我需要在乘法矩阵xbyconstant方法中使用矩阵数组,但我不确定如何使用

C# 我需要在乘法矩阵xbyconstant方法中使用矩阵数组,但我不确定如何使用,c#,arrays,matrix,multidimensional-array,methods,C#,Arrays,Matrix,Multidimensional Array,Methods,我在multilyMatrix XByConstant()中得到一个错误说“没有与所需的形式参数相对应的给定参数”,我不确定要包括哪些参数,以允许我在multilyMatrix XbyConstant()中使用矩阵数组方法 public class Program { public static void Main() { Console.WriteLine(" ----------Welcome to the Matr

我在
multilyMatrix XByConstant()中得到一个错误说“没有与所需的形式参数相对应的给定参数”,我不确定要包括哪些参数,以允许我在
multilyMatrix XbyConstant()中使用矩阵数组方法

    public class Program
{
    public static void Main()
    {
        Console.WriteLine("              ----------Welcome to the Matrix Program----------");
        Console.WriteLine("Please select one of the following options:");
        Console.WriteLine("1: The Random Matrix");
        Console.WriteLine("2: The Transpose Matrix");
        Console.WriteLine("3: Multiplying a Matrix by a Constant");
        Console.WriteLine("4: Multiplying Two Matrices");
        Console.Write("Your choice is: ");
        string choice = Console.ReadLine();
        if (choice == "1")
        {
            generateMatrix();
        }
        else if (choice == "2")
        {
            generateTranspose();
        }
        else if (choice == "3")
        {
            multiplyMatrixByConstant();
        }
    }

    static int[, ] generateMatrix()
    {
        Console.Write("Enter the number of columns: ");
        int c = Convert.ToInt32(Console.ReadLine());
        Console.Write("Enter the number of rows: ");
        int r = Convert.ToInt32(Console.ReadLine());
        int[, ] matrix = new int[c, r];
        Random rnd = new Random();
        Console.WriteLine("The Matrix is: ");
        for (int i = 0; i < c; i++)
        {
            for (int x = 0; x < r; x++)
            {
                matrix[i, x] = rnd.Next(0, 10);
            }
        }

        for (int i = 0; i < c; i++)
        {
            for (int x = 0; x < r; x++)
            {
                Console.Write(matrix[i, x] + " ");
            }

            Console.WriteLine(" ");
        }

        return (matrix);
    }

    static void generateTranspose()
    {
        Console.Write("Enter the number of columns: ");
        int c = Convert.ToInt32(Console.ReadLine());
        Console.Write("Enter the number of rows: ");
        int r = Convert.ToInt32(Console.ReadLine());
        int[, ] matrix = new int[c, r];
        Random rnd = new Random();
        for (int i = 0; i < c; i++)
        {
            for (int x = 0; x < r; x++)
            {
                matrix[i, x] = rnd.Next(0, 10);
            }
        }

        for (int i = 0; i < c; i++)
        {
            for (int x = 0; x < r; x++)
            {
                Console.Write(matrix[i, x] + " ");
            }

            Console.WriteLine(" ");
        }

        Console.WriteLine("The Transpose is:");
        int[, ] transpose = new int[r, c];
        for (int i = 0; i < c; i++)
        {
            for (int x = 0; x < r; x++)
            {
                transpose[x, i] = matrix[i, x];
            }
        }

        for (int i = 0; i < r; i++)
        {
            for (int x = 0; x < c; x++)
            {
                Console.Write(transpose[i, x] + " ");
            }

            Console.WriteLine(" ");
        }
    }

    static void multiplyMatrixByConstant(int[, ] matrix, int c, int r)
    {
        generateMatrix();
        Console.Write(" Enter a Constant to Multiply the Matrix by: ");
        int constant = Convert.ToInt32(Console.ReadLine());
        int[, ] result = new int[c, r];
        for (int i = 0; i < c; i++)
        {
            for (int x = 0; x < r; x++)
            {
                result[i, x] = matrix[i, x] * constant;
            }
        }

        for (int i = 0; i < c; i++)
        {
            for (int x = 0; x < r; x++)
            {
                Console.Write(result[i, x] + " ");
            }

            Console.WriteLine(" ");
        }
    }
}
公共类程序
{
公共静态void Main()
{
Console.WriteLine(“------------欢迎使用矩阵程序-----------------”;
Console.WriteLine(“请选择以下选项之一:”);
Console.WriteLine(“1:随机矩阵”);
控制台.WriteLine(“2:转置矩阵”);
WriteLine(“3:矩阵乘以常数”);
Console.WriteLine(“4:两个矩阵相乘”);
控制台。写(“您的选择是:”);
字符串选项=Console.ReadLine();
如果(选项==“1”)
{
生成矩阵();
}
else if(选项==“2”)
{
生成转换();
}
else if(选项==“3”)
{
乘法矩阵xbyconstant();
}
}
静态int[,]生成矩阵()
{
Console.Write(“输入列数:”);
int c=Convert.ToInt32(Console.ReadLine());
Console.Write(“输入行数:”);
int r=Convert.ToInt32(Console.ReadLine());
int[,]矩阵=新的int[c,r];
随机rnd=新随机();
控制台.WriteLine(“矩阵是:”);
对于(int i=0;i
您需要输入参数,(int[,]矩阵,int c和int r)。

请将您从完整堆栈跟踪中获得的错误添加到问题中。它表示当前上下文中不存在这些参数。您需要自己输入这些参数