I am creating a program that checks repeated letters in a string.
For Example:
wooooooooooowhapppppppppy
This is my
You can change your loop condition to have the -1 (as others have already pointed out), or you can do it the cool kid way.
-1
var text = "wooooooooooow happpppppppy"; var repeats = text.Zip(text.Skip(1), (a, b) => a == b).Count(x => x);