What will be the output of the following C# code snippet? [code] static void Main(string[] args) { string s = " i love you";

Trang Mắm

New member
What will be the output of the following C# code snippet?
Code:
 static void Main(string[] args)
 {
     string s = " i love you";
     Console.WriteLine(s.IndexOf('l') + "  " + s.lastIndexOf('o') + "  " + s.IndexOf('e'));
     Console.ReadLine();
 }
A. 3 5 7
B. 4 5 6
C. 3 9 6
D. 2 4 6
 
Answer: c
Explanation: indexof(‘l’) and lastIndexof(‘o’) are pre-defined function 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:
Code:
3, 9, 6
Code:
 1
000+ C# multiple choice questions focuses on abstract class and methods in C# Programming Language.
 

Tìm kiếm

Back
Top