Remove vowels from a string in c#: c# program to remove or delete vowels from a string, if the input string is "c# programming" then output will be "c# prgrmmng". In the program we create a new string and process entered string character by character, and if a vowel is found it is not added to new string otherwise the character is added to new string, after the string ends we copy the new string into original string. Finally we obtain a string without any vowels.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DemoConsoleApplication
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter a string to remove Vowels:");
string line = Console.ReadLine();
var letters = new HashSet < char > (line);
letters.ExceptWith("AaEeIiOoUu");
Console.WriteLine("String after remove Vowels:");
foreach(char c in letters)
Console.Write(c);
Console.ReadLine();
}
}
}Output:
