Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Tue Jan 04, 2011 8:37 am

how would i use C# in excel to convert string array to List<int>

string strIDs = "15|20|30";
List<int> IDs = strIDs.Split('|').Cast<int>().ToList();

the above code gives error "Specified cast is not valid."

lilyed72
 
Posts: 5
Joined: Mon Dec 27, 2010 1:24 am

Tue Jan 04, 2011 9:23 am

string strIDs = "15|20|30";
List<int> IDs;
string[] strArr = strIDs.Split('|');
int[] intArr = Array.ConvertAll<string, int>(strArr, new Converter<string, int>(Convert.ToInt32));
IDs = intArr.ToList();

8)
e-iceblue support
User avatar

iceblue support
 
Posts: 240
Joined: Tue Dec 21, 2010 2:56 am

Return to Spire.XLS