Tuesday, February 14, 2012

Convert string array to list in c#

Title:How to Convert string array to generic list in asp.net using c#.net

Description:
As in previous articles we have seen the data type conversions.Now i would like to give an example on how to convert the string array to List .To elaborate the example i have used a string "strs".Then it will split and store into array "StrArray".Finally the array is convert to list using below peace code and assign to list details List.
C#:
string strs = "1,1,3,4";
List detailsList;
string[] StrArray = strs.Split(',');
int[] intArray = Array.ConvertAll(strArray, new Converter(Convert.ToInt32));
detailsList = intArray.ToList();
VB:
Dim strs As String = "1,1,3,4"
Dim detailsList As List
Dim StrArray__1 As String() = strs.Split(","C)
Dim intArray As Integer() = Array.ConvertAll(strArray, New Converter(Convert.ToInt32))
detailsList = intArray.ToList()

1 comment:

Unknown said...


Convert your VB programs to C# with over 99% accuracy with the VBConversions VB.Net to C# Converter, the most accurate VB.Net to C# Converter available. Free download available at www.vbconversions.com

convert vb.net to c#

Bel