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
...