CSharp
 
By Firoz AnsariMay 05, 20191 min readComments (0)

Unfortunately there is no method to call DataTable.Add with the column size. This extension method will fix that:

public static DataColumn Add(this DataColumnCollection columns, string columnName, Type type, int maxLength)
{
  DataColumn column = new DataColumn(columnName, type);
  column.MaxLength = maxLength;
  columns.Add(column);

  return column;
}

JOIN THE DISCUSSION
COMMENTS (0)
Copyright © 2021 Firoz Ansari.
All Rights Reserved.