Char String foreach

image_pdfimage_print

   
  

using System;

public class StringSplitForeach
{
    public static void Main()
    {
        string s = "Oh, I hadn't thought of that";
        char[] separators = new char[] {' ', ','};
        
        foreach (string sub in s.Split(separators))
        {
            Console.WriteLine("Word: {0}", sub);
        }
    }
}
           
         
    
     


This entry was posted in Data Types. Bookmark the permalink.