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 174 views
1 answer 148 views
1 answer 164 views
1 answer 146 views
2 answers 238 views
238 views asked Aug 8, 2018 by avibootz
1 answer 258 views
258 views asked Aug 8, 2018 by avibootz
1 answer 162 views
...