C# – A little bit about Lists < T >

In this article I will present some good and worthy examples about the usage of Lists in C#.Net. There are quite a lot good articles for lists and their usage, this one will try to summarize their examples and and give the basics in one place.

myLists

The following examples, for working with Lists are considered valuable by me:

1. Create a list:

2. Access your list with a for each and for loop:

3. If you want to use some of the array functions, you may easily convert the list to an array:

4. If you want to add the dictionary Keys or Values to list, you may do it this way:

5. And if you want to print the dictionary values and keys, without using lists:

6. Lists can be also reversed:

7. Another option is to make a list from a list, using just specific indices of the list (that is what I call a sentence!):

Pretty much, that is all that I needed to remember about lists in C#. If you want to read more, you may do it here.

The united code from the examples is below:

Tagged with: , , ,