Saturday, February 4, 2017

How to remove matching characters from a string using LINQ ?

 string str = "something";
       
 var removeChar= new char[] { 'o', 'e', 'z' };
       
 var y = str.Where(c => !toremove.Contains(c)).ToArray();

 output: smthing

No comments:

Post a Comment