In my application development, I concluded that I need this variable.
IDictionary<string, IDictionary<Levels, IList<Problem>>> PackageDictionaryForProblems
IDictionary<string, IDictionary<Levels, IList<ProblemRule>>> PackageDictionaryForProblemRules
But as I need to access to each key of the dictionary, so it’s a pain. I supposed that would be a good option create a class to avoid write all the datatype:
public class PackageDictionaryForProblems : IDictionary<string, IDictionary<Levels, IList<Problem>>>
{ }
// the sane for the second dictionary
What do you think about this? Is a good practice to create just this class? Or should I need to create several classes for each one? I.E.
public class ProblemCollection : IList<Problem>
{ }
There is no difference at runtype between the two options of defining multi-level collections like
or defining/using a type like
Without any further functionality in
PackageDictionaryForProblems, it simply serves as an alias forIDictionary<string, IDictionary<Levels, IList<Problem>>>.You still end up with the same memory allocation, access times, etc. Adding that custom type only simplifies readability of your code (or not… personally I find it easier to look at the
IDictionary<string, IDictionary<Levels, IList<Problem>>>definition to understand the data structure. That’s just personal preference).