.netlistindexing

How to select List<> by its index and return the content?


I got this sample List<>

List<string> pizzas = new List<string>();
pizzas.Add("Angus Steakhouse");
pizzas.Add("Belly Buster");
pizzas.Add("Pizza Bianca");
pizzas.Add("Classic Cheese");
pizzas.Add("Friday Special");

I just want to know how to return the string using an index?

Like for sample, I will input "1" and it will return "Belly Buster"

Thanks guys!


Solution

  • var str = pizzas[1]; //Tada!!!!