Suppose you have a string "I love Programming"
Output - should be 11.
if there is no word then Output: 0
Output - should be 11.
if there is no word then Output: 0
static void Main1(string[] args)
{
string s = Console.ReadLine();
string[] arr = s.Split(' ');
int length = arr.Length;
Console.WriteLine(arr[length - 1].Length);
Console.ReadLine();
}
Console.WriteLine(s.Length - s.LastIndexOf(" ")-1);
ReplyDelete