static void Main(string[] args) { testClass tc = new testClass(); DataTable dt = tc.getTestData(); for (int i = 0; i < dt.Rows.Count; i++) { Console.WriteLine("Account No {0} Occurence {1}", dt.Rows[i]["ACCNO"].ToString(), dt.Rows[i]["Occurence"].ToString()); } }