To remove all vowels from a string.

image_pdfimage_print
   
 

using System;
using System.Collections.Generic;
using System.Linq;
public class MainClass {
    public static void Main() {

        IEnumerable<char> query = "Not what you might expect";

        query = query.Where(c => c != &#039;a&#039;);
        query = query.Where(c => c != &#039;e&#039;);
        query = query.Where(c => c != &#039;i&#039;);
        query = query.Where(c => c != &#039;o&#039;);
        query = query.Where(c => c != &#039;u&#039;);

        foreach (char c in query) Console.Write(c); 
    }
}

    


This entry was posted in LINQ. Bookmark the permalink.