I have some old school looking code that is as follows:
IList<KeyValuePair<string, ValuePair>> ServicePairs = new List<KeyValuePair<string, ValuePair>>();
// ...
foreach (KeyValuePair<string, string> Set in Services)
{
if (string.Format("{0} (Service)", Set.Value) == c.ColumnName)
{
ServicePairs.Add(new KeyValuePair<string, ValuePair>(c.Ordinal.ToString(), new ValuePair { Id = Set.Key, Title = Set.Value }));
}
}
Resharper is suggesting I pretty it up a bit by converting it to the following:
ServicePairs.AddRange(from Set in Services
where string.Format("{0} (Service)", Set.Value) == c.ColumnName
select new KeyValuePair<string, ValuePair>(
c.Ordinal.ToString(),
new ValuePair { Id = Set.Key, Title = Set.Value }));
What I'd like to know is - where does this AddRange()
method come from - is it from Microsoft Prism or somewhere else?
UPDATE: It's been pointed out that this is part of the List<T>
class. Apparently, it's not part of the IList<T>
interface, which was the source of my confusion. Thanks everyone.
It's a method of the List<T>
class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With