How to use C# in Excel to convert string array to List<int>

Technical support for Spire.XLS

Moderators: iceblue support, Flash, Manager

How to use C# in Excel to convert string array to List<int>

Postby lilyed72 » 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

Re: How to use C# in Excel to convert string array to List<i

Postby iceblue support » 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: 244
Joined: Tue Dec 21, 2010 2:56 am


Return to Spire.XLS

Who is online

Users browsing this forum: No registered users and 0 guests