Home / CSE MCQs / C#.Net MCQs :: Discussion

Discussion :: C#.Net MCQs

  1. 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();
      }
  2. A.
    3 5 7
    B.
    4 5 6
    C.
    3 9 6
    D.
    2 4 6

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    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


Be The First To Comment