text: Print the string after the specified character has occurred given no . of times | C # program for above implementation ; Method to print the string ; If given count is 0 print the given string and return ; Start traversing the string ; Increment occ if current char is equal to given character ; Break the loop if given character has been occurred given no . of times ; Print the string after the occurrence of given character given no . of times ; Otherwise string is empty ; Driver Method
code: using System ; public class GFG { static public void printString ( string str , char ch , int count ) { int occ = 0 , i ; if ( count == 0 ) { Console . WriteLine ( str ) ; return ; } for ( i = 0 ; i < str . Length ; i ++ ) { if ( str [ i ] == ch ) occ ++ ; if ( occ == count ) break ; } if ( i < str . Length - 1 ) Console . WriteLine ( str . Substring ( i + 1 ) ) ; else Console . WriteLine ( " Empty ▁ string " ) ; } static public void Main ( ) { string str = " geeks ▁ for ▁ geeks " ; printString ( str , ' e ' , 2 ) ; } }