private static DataTable CreateWords4Table()
{
string[] words = { "blueberry", "chimpanzee", "abacus", "banana", "apple", "cheese" };
DataTable table = new DataTable("Words4");
table.Columns.Add("word", typeof(string));
foreach (string word in words)
{
table.Rows.Add(new object[] { word });
}
return table;
}
static void Main(string[] args)
{
System.Data.DataTable table = new System.Data.DataTable("TB");
table.Columns.Add("Id", typeof(Int32));
table.Columns.Add("Name", typeof(string));
for (int i = 0; i < 5; i++)
{
table.Rows.Add(new object[]{i,"aa"+i});
}
StringBuilder sb = new StringBuilder();
foreach (DataRow row in table.Rows)
{
foreach(DataColumn columns in table.Columns)
{
Console.Write("{0}:{1}",columns.ColumnName,row.IsNull(columns)?"Null":row[columns]);
}
}
//Console.WriteLine();
//string str = "123456";
//str = str.Substring(0,5);
//Console.WriteLine(str);
//Console.WriteLine(DateTime.Today+"====="+DateTime.Now);
//for (int i = 0; i < table.Rows.Count; i++)
//{
// Console.Write(table.Rows[i]["Id"].ToString()+table.Rows[i]["Name"]);
//}
}