How to split a string in C#

后端 未结 8 916
北海茫月
北海茫月 2021-01-19 23:22

I\'m having a string like

\"List_1 fooo asdf List_2 bar fdsa XList_3 fooo bar\"

and a List like



        
8条回答
  •  春和景丽
    2021-01-19 23:59

    You have to use this split method on msdn, you have to pass your List into an array and then, you have to pass as a parameter of the split that array.

    I leave you the link here

    http://msdn.microsoft.com/en-us/library/tabh47cf(v=VS.90).aspx

    If you want to mantain the words you're splitting with, you will have to iterate the resulted array and then add the words in your list, if you have the same order in the string and in the list.

    If the order is unknown, you mus use indexOf to locate the words in the list and split the string manually.

    See you

提交回复
热议问题