I'm working on a webservice and I'm returning JSON. However, I'm returning a List<KeyValuePair<string, int>>
, since that's all I'm really ever going to be dealing with (property => value)
Now sometimes I myself will be calling these functions to aggregate the results, so I end up with something like
List<KeyValuePair<string, int>> myList = resultList.where(o => o.Key =="StringKEY");
and sometimes
List<KeyValuePair<string, int>> myList = resultList.sum(o => o.Key =="StringKEY");
My question is, would it be more efficient to do the following (custom class vs dictionary):
List<MyObject> myObj = resultObjList.where(o => o.Property1 == "stringProperty")
and so on.
Is there any benefit to using custom objects? I will not ever need to be adding properties, and in this case I can say there will never be a need for additional properties.