Search code examples
c#asp.netasp.net-mvc-5

What does "<employee>" mean in the following code: List<Employee><employee> employees = new List<Employee><employee>();


I am reading an MVC 5 tutorial (Learn MVC Project in 7 days – Day 2). It says to use this code:

List<Employee><employee> employees = new List<Employee><employee>();

I get a red underline. I understand I am trying to create a list of type Employee. (There is an Employee class.) But why don't I do it like this:

List<Employee>employees = new List<Employee>();

What does the <employee> part of the code do? Why do I need it? It's just giving me a red underline. Maybe I need to upgrade to MVC 5 from MVC 4? I'm using Visual Studio 2012 (MVC 4).


Solution

  • This is a typo in the tutorial. You can check here that creating a List has no implementations of List<type><othertype>.

    You may pass a int32 value or IEnumerable<T> which will specify your list size, however List<T><T> simply does not compile.

    Edit: As pointed out in the comments by Ant P, nothing in C# allows for Anything<T><T>, so if you ever run across that, it will not compile.