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

I came across a situation where it Listdoes not have the type specified after it in <>:

List someVar = new List();

However, when I try to do this in Visual Studio, I get an error. What is the reason that VS does not allow me to declare Listthis way?

Let me show you where I saw it:

public override IEnumerable SomeMethod()
        {
            List someVar= new List();
            // more code
            return someVar;
        }

PS After contact with the owner of the project it was found that Wordpress struck tags <>after Listand IEnumerableso in fact it should be List<SomeClass>andIEnumerable<SomeClass>

public override IEnumerable<SomeClass> SomeMethod()
        {
            List<SomeClass> someVar= new List<SomeClass>();
            // more code
            return someVar;
        }
+5
source share
3 answers

List. ArrayList, : List f12. , . :

  • List, List<T>; :

    class List { ...} // here we go; a class called List
    
  • a using alias ( ) List ; :

    using List = System.Collections.Hashtable;
    

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

, List .NET Framework. , , ArrayList.

+2

( , ArrayList , List<T> ?). , , . List<object>.

+1

All Articles