C# (in memory table

what is the meaning of these two lines:
DataTable x = new DataTable();
x.Columns.Add("Code", typeof(int));

I mean conceptually what are they doing (especially in a windows applications). I would like special description of pupose of second line.
vivekj2004Asked:
Who is Participating?
 
Jini JoseConnect With a Mentor Senior .Net DeveloperCommented:
yes, by deafult the column type should be string.
0
 
Jini JoseSenior .Net DeveloperCommented:
DataTable x = new DataTable(); =  you are creating a table. it is not a database table.

x.Columns.Add("Code", typeof(int)); =  you are adding a column of type int to the table x.


below the code is for adding some values to it

DataRow dr=x.NewRow();
dr["Code"]="1"
dt.Rows.Add(dt)



0
 
vivekj2004Author Commented:
if there is no second parameter there e.g.,:
 
       x.Columns.Add("val");
 does this mean that the column type will be string?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.