How to Create DataTable and add rows in C#?

Below is a sample code snippet demonstrating how to create DataTable in C# and then add rows to the datatable.

How to Create DataTable and add rows in C#?

DataTable dt = new DataTable();

dt.Columns.Add("Name");

dt.Columns.Add("Code");

DataRow row1 = dt.NewRow();

row1["Name"] = "Abundantcode";

row1["Code"] = "1-1-1";

dt.Rows.Add(row1);