使用 array.ElementAt(0);
我们可以获得数组索引 0 处的元素。有没有办法获取数组中的所有元素?
string[] arr1 = {'abc', 'def', 'ghi'}
Library.Results["TEST_ACTUALVALUE"] = "The results are: " + arr1;
TEST_ACTUALVALUE 是我的 report.xls 文件中的一列。上面在我的 excel 文件中写入了 System.string[]。
最佳答案
您已经拥有数组中的所有元素……数组本身。
简单的答案是迭代它们:
foreach(var item in array)
{
// work with item here
}
或者如果您更愿意处理索引:
for(var i = 0; i < array.Length; i++)
{
var item = array[i];
// work with item here
}
关于C#获取数组的所有元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6614228/