【发布时间】:2012-06-14 15:00:39
【问题描述】:
我有一个二维数组object[,] data;。我想将对象的第一列转换为list<string> 或list<object>。这里有我的代码:
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]) 转换为列表
【问题讨论】:
标签: c# arrays list object casting