KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Suppose I have two classes with the same interface: interface ISomeInterface { int foo{get; set;} int bar{get; set;} } class SomeClass : ISomeInterface {} class SomeOtherClass : ISomeInterface {} Suppose I have an instance of ISomeInterface that represents a SomeClass. Is there an easy way to copy that into a new instance of SomeOtherClass without copying each member by hand? UPDATE: For the record, I'm not trying to cast the instance of SomeClass into the instance of SomeOtherClass. What I'd like to do is something like this: ISomeInterface sc = new SomeClass() as ISomeInterface; SomeOtherClass soc = new SomeOtherClass(); soc.foo = sc.foo; soc.bar = soc.bar; I just don't want to have to do that for each by hand as these objects have lots of properties.
Tags (comma-separated)
Save Edits
Cancel