Number of substrings of a string | C # program to count number of substrings of a string ; Driver Code
using System ; class GFG { static int countNonEmptySubstr ( string str ) { int n = str . Length ; return n * ( n + 1 ) / 2 ; } public static void Main ( ) { string s = " abcde " ; Console . Write ( countNonEmptySubstr ( s ) ) ; } }