Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Split a string in C#

We can split a string by the use of split function by specifying the delimiter.
Here we use space delimiter {' '}.

  1. using System;
  2. using System.IO;
  3. using System.Text;
  4.  
  5. namespace forgetCode
  6. {
  7. class program1
  8. {
  9. static void Main(string[] args)
  10. {
  11. string MainString = "Forget code";
  12. string[] Split = MainString.Split(new Char[] { ' ' });
  13.  
  14. Console.WriteLine(Convert.ToString(Split[0]));
  15. Console.WriteLine(Convert.ToString(Split[1]));
  16. }
  17. }
  18. }

Output:

Forget
code

..