C# new class with only single property : derive from base or encapsulate into new ?
- by Gobol
I've tried to be descriptive :) It's rather programming-style problem than coding problem in itself.
Let's suppose we have :
A:
public class MyDict {
public Dictionary<int,string> dict;
// do custom-serialization of "dict"
public void SaveToFile(...);
// customized deserialization of "dict"
public void LoadFromFile(...);
}
B:
public class MyDict : Dictionary<int,string>
{
}
Which option would be better in the matter of programming style ?
class B: is to be de/serialized externally.
Main problem is : is it better to create new class (which would have only one property - like opt A:) or to create a new class derived - like opt B: ?
I don't want any other data processing than adding/removing and de/serializing to stream.
Thanks in advance!