{
List
If (dt. Rows. Count & gt; 0)
{
Lists=new List
//traverse table each row record
Foreach (DataRow row in dt. Rows)
{
//each line corresponds to a data object
Bianwen temp=new bianwen ();
Temp. Materials=row [" Materials "). The ToString ();
if (! (row [" Condiction "] is DBNull | | string. IsNullOrEmpty (row [" Condiction "]. ToString ())))
{
Temp. Condiction=row [" Condiction "]. ToString ();
}
Temp. Mocaxishu=(int) row [" Mocaxishu "];
Temp. Mosunliang=(int) row [" Mosunliang "];
//add objects to the collection
Lists. The Add (temp);
}
}
Return lists.
}
}
}
Temp. Mocaxishu=(int) row [" Mocaxishu "]; Exception: System. InvalidCastException: "the specified transformation is invalid,"
For help
CodePudding user response:
Mosunliang you this is a list of type int, you to look at the column of dataCodePudding user response:
Is the decimal, but is I use floatCodePudding user response: