Reputation: 2859
I have this code. I want to access the "Name" attribute of the object because type contains something like
{Name="String", FullName="System.String"}
but i want only "string".
DataTable dt = dr.GetSchemaTable();
foreach (DataRow myField in dt.Rows){
var name = myField["ColumnName"];
var type = myField["DataType"];
Console.Out.WriteLine("type = " + type.toString());
}
ideas ?
Upvotes: 0
Views: 88
Reputation: 1038820
You could cast to the corresponding type and then access the Name property:
var type = (Type)myField["DataType"];
Console.WriteLine("type = " + type.Name);
Upvotes: 4