If we want to add a column in a table at a particular position.To do this task we use the DataTable function SetOrdinal().For this function we use the namespace:System.Data;We have a DataTable with some columns:DataTable dt = new DataTable();dt.Columns.Add("ID");dt.Columns.Add("FirstName");dt.Columns.Add("LastName");dt.Columns.Add("Address");dt.Columns.Add("City");The table structure is:
Now we want to add a PhoneNo column after the LastName column. For this we use the SetOrdinal function, as iin:dt.Columns.Add("PhoneNo").SetOrdinal(3);3 is the position number and positions start from 0.Now the table structure will be:
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: