Convert Array of Objects to a Generic List

Working with generic lists is a lot easier and fun than working with arrays.  
To convert an array to a generic list use the following code.  (List of string in example)
 
C#
string stringSet = "a,b,c,d";
string[] stringArray = stringSet.Split(new char[] { ',' });
System.Collections.Generic.List<string> genericList = new System.Collections.Generic.List<string>(stringArray);
 

VB.NET

 

Dim stringSet As String = "a,b,c,d"
Dim stringArray() = stringSet.Split(",")
Dim genericList As New List(Of String)(stringArray)

7 Comments

Comments have been disabled for this content.