How to split string into array of words in C#

1 Answer

0 votes
using System;
  
class Program
{
    static void Main() {
        string name = "James John William";
  
        var arr = name.Split(' ');
  
        foreach (string s in arr) {
           Console.WriteLine(s);
        }
    }
}
  
  
  
/*
run:
     
James
John
William
     
*/

 



answered Nov 24, 2021 by avibootz

Related questions

1 answer 159 views
1 answer 126 views
1 answer 143 views
1 answer 133 views
2 answers 224 views
224 views asked Aug 8, 2018 by avibootz
1 answer 239 views
239 views asked Aug 8, 2018 by avibootz
1 answer 149 views
...