Question
What will be the output for the given code snippet?
static void Main(string[] args)Â {Â Â Â string s = " i love you";Â Â Â Console.WriteLine(s.IndexOf('l') + "Â " + s.lastIndexOf('o') + "Â " + s.IndexOf('e'));Â Â Â Console.ReadLine();Â }
static void Main(string[] args)Â {Â Â Â string s = " i love you";Â Â Â Console.WriteLine(s.IndexOf('l') + "Â " + s.lastIndexOf('o') + "Â " + s.IndexOf('e'));Â Â Â Console.ReadLine();Â }
Answer: Option C
Was this answer helpful ?
indexof('l') and lastIndexof('o') are pre defined functions which are used to get the index of first and last occurrence of
the character pointed by l and c respectively in the given array.
Output : 3, 9, 6
Was this answer helpful ?
Submit Solution