using System.Collections.Generic;
public int Longest(string mySequence, char c = '\0')
for (int i = 0; i < mySequence.Length; i++)
char thisChar = mySequence[i];
if (c != '\0' && thisChar != c)
for (int j = i + 1; j < mySequence.Length; j++)
char nextChar = mySequence[j];
if (thisChar != nextChar)
if (currentCount > charCount)
charCount = currentCount;
static void Main(string[] args)
CarCounting newSequence = new CarCounting();
Console.WriteLine(newSequence.Longest("CCMCCCCLLCCC", 'C'));