Hi guys,
I'm looking into MVC and I'm reasing this tutorial http://www.asp.net/mvc/overview/older-versions/hands-on-labs/aspnet-mvc-4-fundamentals
I've got to the point of adding a model and the class they add is this:

public class StoreIndexViewModel
  public int NumberOfGenres { get; set; }
  public List<string> Genres { get; set; }

I'm not really familiar with this syntax public List<string> Genres and I was wondering if anybody can help me understanding this a bit better. They refer to it as a list of string, so why not use an array of strings? Is that also what they call a "generic"? How do I get values in that list of string and how do I get them out please?

Sorry, please do ignore my post. Thought it is in php section.


This is indeed a Generic List.

You can create a List of anything eg List<Customer> or List<Invoice>

To Add things you just use:

var model = new StoreIndexViewModel();


You can pull them all out with things like:

foreach (var genre in mode.Genres)
    //Do something with genre here

Why is this better than an array? Many reasons. Check out this video:


OK thanks for your help with that!