When creating C# generic classes with static functions should the return type concreate class types?
For example:
And what about returning the same class from deserialization?
And what about returning the same class from deserialization?
public class MyClass<TKey, TValue> : IBase
{
TValue v;
public Dictionary<TKey, TValue> myData = new Dictionary<TKey, TValue>();
public Dictionary<TKey, TValue> GetData() { return myData; }
public static MyClass<string, MyData> CreateMyData()
{
MyClass<string, MyData> tmp = new MyClass<string, MyData>();
return tmp;
}
}public static MyClass<string, MyData> Deserialize(string filename)
{
string jsonString = File.ReadAllText(filename);
MyCall<string, MyData> tmp = JsonSerializer.Deserialize<MyClass<string, MyData>>(jsonStrin);
return tmp;
}