Cast into new Object, Copy values by Property Name

Posted by Alex on Stack Overflow See other posts from Stack Overflow or by Alex
Published on 2010-05-24T04:08:19Z Indexed on 2010/05/24 4:10 UTC
Read the original article Hit count: 204

Filed under:
|

Hello, I have the following:

Class 1 (Text, State, Level)
Class 2 (Text, State, Level, Ident)

Is there a way for me to cast an object of Class 2 into into Class 1, and not having to do the usual cast code (Text = c.Text, State = c.State etc.)? Possibly by identifying the property names of each class and copying the value over?

© Stack Overflow or respective owner

Related posts about c#

Related posts about cast