How can a List exist without <T> after it?

c#, list, types

Solution

There is not an inbuilt class called `List`. There is `ArrayList`, but: click on `List` and press f12. This will show you where it is declared. There are two options:

a class called `List` that is nothing whatsoever to do with `List<T>` has been declared in the local project; for example:

class List { ...} // here we go; a class called List

a `using` alias (at the top of the file) has been used to spoof `List` as a name; for example:

using List = System.Collections.Hashtable;

or

using List = System.Collections.Generic.List<int>;

Problem

I came across this situation where `List` has no type specified after it in `<>`: ``` List someVar = new List(); ``` However when I try this in Visual Studio I get an error. What is the reason for VS not letting me declare `List` this way? Let me show you where I saw it: ``` public override IEnumerable SomeMethod() { List someVar= new List(); // more code return someVar; } ``` P.S After contacting the owner of the project it turned out Wordpress striped out the tags `<>` after `List` and `IEnumerable`, so it actually should be `List<SomeClass>` and `IEnumerable<SomeClass>` ``` public override IEnumerable<SomeClass> SomeMethod() { List<SomeClass> someVar= new List<SomeClass>(); // more code return someVar; } ```

Original source