Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create and populate a List<string[]> in line? (C#)

Tags:

c#

I need to create and populate in line (is there a word for this operation?) an instance of List<string[]>. How do I do that?

like image 831
user1306322 Avatar asked Sep 07 '12 14:09

user1306322


People also ask

How do you populate a list of strings?

Create list of strings. To create a list of strings, first use square brackets [ and ] to create a list. Then place the list items inside the brackets separated by commas. Remember that strings must be surrounded by quotes.

How to define string list in C#?

The following example shows how to create list and add elements. In the above example, List<int> primeNumbers = new List<int>(); creates a list of int type. In the same way, cities and bigCities are string type list. You can then add elements in a list using the Add() method or the collection-initializer syntax.


1 Answers

var test = new List<string> { "test", "test2" };
like image 81
Big Daddy Avatar answered Sep 23 '22 12:09

Big Daddy