2015-02-10 123 views

回答

1

試試這個:

static public IEnumerable<DataColumn> GetColumns(DataTable dt) 
    { 
     var names = new[] { "foo", "bar" }; 
     return dt.Columns.OfType<DataColumn>().Where(c => names.Contains(c.ColumnName)); 
    } 
0
public string getcolumns(DataTable dt,string[] array) 
    { 
     string columns = ""; 
     foreach (DataColumn column in dt.Columns) 
     { 
      if(array.Contains(column.ColumnName)) 
      { 
      columns += column.ColumnName + ","; 

      } 
     } 
     return columns; 
    } 
+0

試試這個方法 – Meer 2015-02-10 11:00:01

相關問題