Hi,
how can I dynamicly cast variables? Below is a sample that of course doesn't work but it gives you the picture what I'm trying to do.
Any help is appreciated,Code:DataTable table; //.... foreach (DataColumn column in table.Columns) { switch (column.ColumnName) { case "MyProperty1": this.MyProperty1 = (this.MyProperty1.GetType())table.Rows[0][column.ColumnName]; break; case "MyProperty2": this.MyProperty2 = (this.MyProperty2.GetType())table.Rows[0][column.ColumnName]; break; } }
Thanx in advance.




Reply With Quote