C# 数据[,]进入列表<;字符串>;或列表<;对象>;在c中#

C# 数据[,]进入列表<;字符串>;或列表<;对象>;在c中#,c#,arrays,list,object,casting,C#,Arrays,List,Object,Casting,我有一个二维对象[,]数据数组。我想将对象的第一列转换为列表或列表。这是我的密码: 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); i

我有一个二维
对象[,]数据数组。我想将对象的第一列转换为
列表
列表
。这是我的密码:

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());
}
List resultsFields=new List();
对象tmp=oRtx.get_列表字段(this.Instrument.ElementAt(i).Key.ToString(),RT_FieldRowView.RT_FRV_EXISTING,RT_FieldColumnView.RT_FCV_VALUE);
如果(tmp!=null)
{
object[,]data=(object[,])Convert.ChangeType(tmp,typeof(object[,]);
对于(int j=0;j
在这段代码中,我将
data[j,0]
上的每个项目添加到我的列表中。
我想知道是否有更快的方法将我的对象的第一列(
[0]
)转换为列表

我能看到的唯一性能改进是创建具有指定容量的列表:

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