How would i convert string array to List

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();

Using LINQ you could have

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


About eagle081183

Passionate, Loyal
This entry was posted in C#. Bookmark the permalink.

One Response to How would i convert string array to List

  1. eagle081183 says:

    result = endecaQuery.SearchFilterPrice(objectId, searchKey, refineCollection, searchMode, itemCount, pageNumber, sortByKey, sortOrder.ToString(), priceRange, DidYouMeanState.DisableDYM);

    //// Try to use new Endeca method
    ////var item = Array.ConvertAll(objectId.Split(new char[] { Constant.CONCATENATESIGN[0] }), new Converter(Convert.ToInt32)).ToList();
    List ids = objectId.Split(new char[] { Constant.CONCATENATESIGN[0] }).Select(s => long.Parse(s)).ToList();
    SearchBuilder searchBuilder = new SearchBuilder();
    searchBuilder.AddSearch(refineCollection, searchMode, searchTerms);
    SortBuilder builder = new SortBuilder();
    builder.AddSort(sortByKey, (SortOrderType)sortOrder);
    FilterBuilder filter = new FilterBuilder();
    endecaQuery.Search(ids, itemCount, pageNumber, null, null, null);

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s