C#中多维数组double[,]和数组数组之间有什么区别double[][]?
如果有差异,每个人的最佳用途是什么?
我用了
double [,] marks=new double[26,5]
int[] function = object.verify(marks)
public void verifymarks(double[][] marks)
Run Code Online (Sandbox Code Playgroud)
我得到的错误是无法从双[ , ] 转换为双[] []我试图在互联网上搜索但无法找到任何解决方案.我刚刚开始使用c#.请帮忙.THankx提前
我在C#中混淆了double [] []和double [,].
我的队友给我一个这样的功能:
public double[][] Do_Something(double[][] A)
{
.......
}
Run Code Online (Sandbox Code Playgroud)
我想使用这个功能:
double[,] data = survey.GetSurveyData(); //Get data
double[,] inrma = Do_Something(data);
Run Code Online (Sandbox Code Playgroud)
它导致错误:无效的参数.
我不想编辑我队友的代码.
有没有办法转换double[][]成double [,]?
谢谢!
如果我有1到100位数,我应该得到输出
1--100
2--99
3--98
.
..
..
49---50
Run Code Online (Sandbox Code Playgroud)
代码低于其给定索引的范围,数组不需要很多维度
static void Main(string[] args)
{
//// A. 2D array of strings.
string[][] a = new string[100][];
int bound0 = a.GetUpperBound(0);
int bound1 = a.GetUpperBound(1);
for (int i = 0; i <= bound0; i++)
{
for (int x = 100; x <= bound1; x--)
{
string s1 = a[i][x];
Console.WriteLine(s1);
}
}
Console.WriteLine();
Console.ReadKey();
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试制作一个添加矩阵的行和列的应用程序。该应用程序背后的逻辑是,您在文本框中在矩阵的每一行中输入一行,并用“ /”分隔每一行。例如:1 2 3 4/1 2 3 4.我试图将值从字符串转换为整数,但是我不断收到参数1错误。
编辑:忘记添加添加行的功能。
if (decision == 2)
{
string[] tokens = a.Split('/');
int[][] tokens1 = new int[][] {
tokens[0].Split(' ').Select(Int32.Parse).ToArray(),
tokens[1].Split(' ').Select(Int32.Parse).ToArray()
};
row_sum(tokens1, 2);
}
static void row_sum(int[,] arr, int orden)
{
int i, j, sum = 0;
// finding the row sum
for (i = 0; i < orden; ++i)
{
for (j = 0; j < orden; ++j)
{
// Add the element
sum = sum + arr[i, j];
}
// …Run Code Online (Sandbox Code Playgroud)