Reputation: 1839
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.
Upvotes: 2
Views: 1845
Reputation: 32807
You would need a copy constructor
You can also implement ICloneable interface or create your own interface
this would also help you!
Upvotes: 6