get only 3 words of a String in C#

后端 未结 2 466
傲寒
傲寒 2021-01-29 14:59

I\'m trying to grab the first 3 words of a string (E-mail Subject)in C#, has anyone done this before? thanks for your help

相关标签:
2条回答
  • 2021-01-29 15:12
    List<string> myWordsList = myWords.Split(' ').Take(3).ToList();
    
    0 讨论(0)
  • 2021-01-29 15:24

    string result = string.Join(" ", str.Split().Take(3)); (Edited)

    0 讨论(0)
提交回复
热议问题