This is a compiler error (slightly changed for readability).
This one always puzzled me. FxCop tells that this is a bad thing to return List and classes that are\\de
Here is a generic extension method written in C# 3.0 used to convert List to Collection
using System.Collections.Generic;
using System.Collections.ObjectModel;
public static class ExtensionMethods
{
public static Collection ToCollection(this List items)
{
Collection collection = new Collection();
for (int i = 0; i < items.Count; i++)
{
collection.Add(items[i]);
}
return collection;
}
}
and it is used like this…
List entities = new List();
entities.Add("Value 1");
entities.Add("Value 2");
entities.Add("Value 3");
entities.Add("Value 4");
Collection convertedEntities = entities.ToCollection();