2012-06-14 99 views
0

我有一个二维数组object[,] data;。我想将我的对象的第一列转换为list<string>list<object>。在这里你有我的代码:数据[,]到列表<string>或列表<object>在c#

List<string> resultsFields = new List<string>(); 

object tmp = oRtx.get_ListFields(this.Instrument.ElementAt(i).Key.ToString(), RT_FieldRowView.RT_FRV_EXISTING, RT_FieldColumnView.RT_FCV_VALUE); 
if (tmp != null) 
{ 
    object[,] data = (object[,])Convert.ChangeType(tmp, typeof(object[,])); 
    for (int j = 0; j < numItems; j++) 
     resultsFields.Add(data[j, 0].ToString()); 
} 
在这段代码

,我加上data[j, 0]每个物品进入我的列表。 我想知道如果有我的对象([0])的第一列转换成一个列表

回答

2

唯一的性能改善,我可以看到的是创建列表<>规定容量更快的方法:

List<string> resultsFields = new List<string>(data.GetLength(0));