TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Deepak Awashti
NA
301
74.6k
how to show datatable data in console application using c#
Aug 7 2016 3:59 AM
how to show datatable data in console application using c# code
please help :
i provide txt file nd my create code ....
class Program
{
static void Main(string[] args)
{
DataTable table = new DataTable("Orders");
table.Columns.Add("Population", typeof(Int32));
table.Columns.Add("State", typeof(string));
table.Columns.Add("City", typeof(string));
table.Columns.Add("InterState", typeof(string));
int[] districtDataD = new int[100];
string[] districtDataG = new string[90];
string[] districtDataM = new string[90];
string[] districtDataA = new string[100];
int i = 0;
Console.WriteLine("Enter FilePath:");
string a = Console.ReadLine();
foreach (string line in File.ReadAllLines(a))
{
if (line == null)
{
break;
}
string[] parts = line.Split('|');
if (parts.Length == 4)
{
districtDataD[i] = int.Parse(parts[0]);
districtDataG[i] = parts[1];
districtDataM[i] = parts[2];
districtDataA[i] = parts[3];
}
DataRow newRow = table.NewRow();
newRow["Population"] = districtDataD[i];
newRow["State"] = districtDataG[i];
newRow["City"] = districtDataM[i];
newRow["InterState"] = districtDataA[i];
table.Rows.Add(newRow);
i++;
var Rows = (from row in table.AsEnumerable()
orderby row["Population"], row["State"],row["City"] ascending
select row);
table = Rows.AsDataView().ToTable();
Console.WriteLine(table);
}
Console.WriteLine();
Console.ReadKey();
}
}
Attachment:
sample-cities.rar
Reply
Answers (
1
)
Which is better of these two class diagrams calculator ?
How can i set in chart Series Database value