Question

I have a dictionary such that: Dictionary<string, SomeClass> template

Basically, what I want to do is get a copy of the object contained in template. However, I can't seem to create a method that will retrieve the object by value. I am aware of ref and out, but these are the exact opposite of what I want. A struct would be perfect, but unfortunately, SomeClass must inherit from another class and/or an interface.

Is there some way to do what I want? This seems like it should be really simple.

Was it helpful?

Solution

You would need a copy constructor

You can also implement ICloneable interface or create your own interface

this would also help you!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top