Commonly we need to find the characters in a string which are not repeated or which occurs only once.We can use the following LINQ example to find such characters.
Though this is a short string but you can see that even in this string all characters are repeated except M,L and O.
We first iterate through the string characters one at a time.Then we compare if the last index of that character is same as the first index.If that is the case then we return that element.
public class Program
public static void Main(string args)
string examplestring=”THIS IS A SIMPLE STRING TO TEST REPEATING CHARACRTERS”;
foreach(var ch in chars)
Leave a Reply