Perform Trim() while using Split()

后端 未结 7 1229
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-23 15:53

today I was wondering if there is a better solution perform the following code sample.

string keyword = \" abc, foo  ,     bar\";
string match = \"foo\";
str         


        
7条回答
  •  抹茶落季
    2020-12-23 16:53

    var parts = line
        .Split(';')
        .Select(p => p.Trim())
        .Where(p => !string.IsNullOrWhiteSpace(p))
        .ToArray();
    

提交回复
热议问题