Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
BlueHost Web Hosting

Bonsai Boy of New York Bonsai Trees and Accessories

Liquid Web iThemes WordPress Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

DreamHost Web Hosting

getResponse autofunnels

Liquid Web Cloud VPS Hosting

Disclosure We are a professional Information website that receives compensation from some of the links whose we show you with Information. It means that my content may contain affiliate links.

12,160 questions

16,563 answers

573 users

How to check if a string contain only three same repeating characters in C#

1 Answer

0 votes
using System;
class Program
    static bool contain_only_three_same_repeating_chars(string s)  {  
        int len = s.Length;
        if (len % 3 != 0) return false;
        for (int i = 0; i < len - 3; i++) {  
            if (s[i] != s[i + 3]) {  
                return false;  
        return true;  
    static void Main() {
        string s = "abcabcabcabc";  
        if (contain_only_three_same_repeating_chars(s))  


answered Jan 8 by avibootz
edited Jan 8 by avibootz