0 votes
23 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.4k points)   | 23 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.3k points)  

Related questions

+1 vote
1 answer
+1 vote
1 answer
asked May 26, 2020 by toheed (1.4k points) | 20 views
+1 vote
1 answer
asked May 26, 2020 by toheed (1.4k points) | 24 views
+3 votes
3 answers
asked May 21, 2020 by athar (3.3k points) | 130 views
+1 vote
1 answer
asked May 26, 2020 by toheed (1.4k points) | 66 views
0 votes
1 answer
+2 votes
1 answer
+3 votes
0 answers
+2 votes
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.
131 questions
94 answers
44 comments
134 users