0 votes
14 views

How do create a DataTable in C#?

I did like this:

 DataTable dt = new DataTable();
 dt.DataSource = source;

How can I check the structure of the datatable and how can I add or remove specific columns and rows from the datatable?

by (1.3k points)   | 14 views

1 Answer

+1 vote

You can simply pass an object like this

DataTable datat = new DataTable();
datat.Columns.Add("Name");
datat.Columns.Add("Class");
object[] row = { "Athar", "BS.SE" };
datat.Rows.Add(row);

This will add new row according to the columns.

by (3.2k points)  

Related questions

+1 vote
1 answer
+1 vote
1 answer
asked May 27 by toheed (1.3k points) | 12 views
+1 vote
1 answer
+2 votes
3 answers
+1 vote
1 answer
asked May 27 by toheed (1.3k points) | 16 views
+2 votes
1 answer
+3 votes
0 answers
+1 vote
2 answers




Welcome to Meansflow - Where Developers and Students Learn, Share, & Build Careers, where you can ask questions and receive answers from other members of the community.
117 questions
87 answers
40 comments
105 users