Program for length of the longest word in a sentence | C # program to find the number of charters in the longest word in the sentence . ; Driver code
using System ; class GFG { static int LongestWordLength ( string str ) { String [ ] words = str . Split ( ' ▁ ' ) ; int length = 0 ; for ( int i = 0 ; i < words . Length ; i ++ ) { if ( length < words [ i ] . Length ) { length = words [ i ] . Length ; } } return length ; } static void Main ( ) { string str = " I ▁ am ▁ an ▁ intern ▁ at ▁ geeksforgeeks " ; Console . Write ( LongestWordLength ( str ) ) ; } }