This C# doesn't compile:
public class IdList<T> where T : IdList<T>.Item {
List<T> List = new List<T>();
public T this[int id] {
get => List[id];
set { }
}
public class Item {
public int id;
// Not shown: id used for equality and hash.
}
}
The complaint from the compiler is:
The type 'IdList' already contains a definition for 'Item'
If I comment out the indexer, it compiles.
How can I get this to compile? Rider doesn't have a fixit.
The unstylish workaround is not to nest the Item class.
IDE is Rider 2018.1.4, Language level 7.2, on macOS.
Item
toFoo
...