本文介绍了多维与锯齿状数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用了如下的多维数组
I have used a MultiDimesional Array as follows
string[,] Columns = { { "clientA", "clientB" }}
if (Columns.Length != 0)
{
for (int i = 0; i < Columns.Length / 2; i++)
{
bulkCopy.ColumnMappings.Add(Columns[i, 0], Columns[i, 1]);
}
}
代码分析后,我收到警告消息,
After code analysis I got warning message as
Severity Code Description Project File Line Suppression State
Warning CA1814 'Order.GetLastOrderID()' uses a multidimensional array of
'string[,]'. Replace it with a jagged array if possible.
我已经在互联网上研究了锯齿状阵列,但是如何用锯齿状阵列替换我的阵列.
I have researched jagged arrays on internet but How do I replace my array with jagged array.
推荐答案
锯齿状的数组是数组的数组,因此您将定义更改为:
A jagged array is an array of arrays, so you change your definition to:
string[][] Columns = { new string[] { "clientA", "clientB" }};
从...更改阵列访问权限
Change array access from...
var value = Columns[0,0];
...到...
var value = Columns[0][0];
您还可以选择禁止显示警告(右键单击警告,然后选择所需的选项). 根据MSDN ,此警告可以安全地在某些情况下.在更改代码之前,请检查您的情况是否如此.
You also have the option to suppress the warning (right-click on it and select the option you need). According to MSDN, this is a warning that is safe to suppress in certain cases. Check if yours is such a case before you change the code.
这篇关于多维与锯齿状数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!