Checks if the string has all the same letter/number - CSharp System

CSharp examples for System:String Number

Description

Checks if the string has all the same letter/number

Demo Code


using System.Text.RegularExpressions;
using System.Text;
using System.Globalization;
using System.Collections.Generic;
using System;//from  w  ww. ja  va2s.  c o m

public class Main{
        //Checks if the string has all the same letter/number
        //aaaaaaaaaaaaaaaaaaa -> true
        //aaaaaaaaaaaaaaaaaab -> false
        public static bool IsRepeatedChar(string input)
        {
            if (input.Length == 0) return false;
            return input.Replace(input.Substring(0, 1), "").Length == 0;
        }
}

Related Tutorials