Number of sub | C # implementation of the approach ; Function to return the count of the required substrings ; To store the final answer ; Loop to find the answer ; Condition to update the answer ; Driver code
using System ; class GFG { static int countSubStr ( string str , int len ) { int ans = 0 ; for ( int i = 0 ; i < len ; i ++ ) { if ( str [ i ] == '0' ) ans += ( i + 1 ) ; } return ans ; } public static void Main ( ) { string str = "10010" ; int len = str . Length ; Console . WriteLine ( countSubStr ( str , len ) ) ; } }