I'm trying to make a list be able to added to by plusing an item into it.
Target use of code I'm trying to make happen:
List<int> numbers = new List<int>();
numbers += 10;
What I've tried. "operator +" should overload + and "this IList" should extend generic IList.
public static IList<T> operator +<T>(this IList<T> list, T element)
{
list.Add(element);
return list;
}
It's not working however, red underlines everywhere over it in visual studios 2012. What am I doing wrong? Is this not possible? Why could this work for a standard class but not a generic class?