Spire.XLS for .NET is a professional Excel .NET library that can be used to any type of .NET( C#, VB.NET, ASP.NET, .NET Core) application, both ASP.NET web sites and Windows Forms application.

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