Currently 'TryValidate' method returns IDictionary<string, string[]>. If we look at the implementation of the 'TryValidate' method, it first creates Dictionary<string, List<string>> then it maps it to Dictionary<string, string[]> using the ToArray method. But can't it just return the Dictionary<string, List<string>>? What's the problem with it? Mapping it using ToArray causes it to create new arrays,
It's not like arrays are immutable. For immutable behavior IEnumerable or even better IReadOnlyCollection would be much better as they won't allocate new collections.
Maybe I'm missing something on the intention of returning arrays. Let me know.
Currently 'TryValidate' method returns
IDictionary<string, string[]>. If we look at the implementation of the 'TryValidate' method, it first createsDictionary<string, List<string>>then it maps it toDictionary<string, string[]>using theToArraymethod. But can't it just return theDictionary<string, List<string>>? What's the problem with it? Mapping it usingToArraycauses it to create new arrays,It's not like arrays are immutable. For immutable behavior
IEnumerableor even betterIReadOnlyCollectionwould be much better as they won't allocate new collections.Maybe I'm missing something on the intention of returning arrays. Let me know.