将特定列的位置保存在数据表中... [英] Save specific column position in a data table...

查看:38
本文介绍了将特定列的位置保存在数据表中...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都知道执行此操作的其他方法:

Anybody knows other way of doing this:

for (int i = 0; i < columnscount; i++)
{
  if (dt.Columns[i].ColumnName.ToString() == "ID")
  {
     int idcol = i;
  }
}


我试过用这个,


I tried using this,

dt.Columns.Contains("ID");


但没有太大帮助,因为我需要列ID位置.


but not much help, because I need the column ID position.

推荐答案

int idcol = dt.Columns["ID"].Ordinal;


矮一点吧?


Shorter, huh?


这篇关于将特定列的位置保存在数据表中...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆