using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; namespace DataTableExample { class Program { static void Main(string[] args) { DataTable table = new DataTable("mytable"); DataColumn col0 = new DataColumn("id", System.Type.GetType("System.Int32")); col0.AutoIncrement = true; col0.AutoIncrementSeed = 0; col0.AutoIncrementStep = 1; DataColumn col1 = new DataColumn("name", System.Type.GetType("System.String")); DataColumn col2 = new DataColumn("age", System.Type.GetType("System.Int32")); table.Columns.Add(col0); table.Columns.Add(col1); table.Columns.Add(col2); DataRow row1 = table.NewRow(); row1["name"] = "John"; row1["age"] = 56; DataRow row2 = table.NewRow(); row2[1] = "Bill"; row2[2] = 41; table.Rows.Add(row1); table.Rows.Add(row2); Console.WriteLine(table.Rows[1]["name"]); Console.ReadLine(); } } }