using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication24
{
class Program
{
static void Main(string[] args)
{
DataTable tblEmp = new DataTable();
tblEmp.TableName = "emp";
DataColumn colEmpNo = new DataColumn("empno", typeof(int));
DataColumn colEmpName = new DataColumn("empname");
DataColumn colAddress = new DataColumn("address");
tblEmp.Columns.Add(colEmpNo);
tblEmp.Columns.Add(colEmpName);
tblEmp.Columns.Add(colAddress);
//================method 2==============================
DataTable tblEmp2 = new DataTable("emp");
tblEmp2.Columns.Add("empno", typeof(int));
tblEmp2.Columns.Add("empname");
tblEmp2.Columns.Add("address");
//===============================
Console.WriteLine(tblEmp2.Columns[0].DataType);
Console.WriteLine(tblEmp2.Columns[1].DataType);
Console.WriteLine(tblEmp2.Columns[2].DataType);
Console.WriteLine(tblEmp.Columns["empno"].DataType);
Console.WriteLine(tblEmp.Columns["empname"].DataType);
Console.WriteLine(tblEmp.Columns["address"].DataType);
Console.WriteLine(tblEmp2.Columns["address"].ColumnName);
Console.WriteLine(tblEmp.Columns.Count);
for (int x = 4; x <= 15; x += 1)
{
tblEmp2.Columns.Add("columnno " + x);
}
Console.WriteLine(tblEmp2.Columns.Count);
Console.WriteLine(tblEmp2.Columns[0].DataType);
Console.WriteLine(tblEmp2.Columns[14]);
}
}
}