Learn C# .Net MCQs

Prepare C# .Net MCQs (Multiple choice Questions) for exam and job interviews.

Which of the following is a valid event declaration in C#?

1) public event EventHandler MyEvent;

2) event MyEventHandler;

3) public MyEvent;

4) None of the above

Answer : public event EventHandler MyEvent;

What is the output of Console.WriteLine("5" + "5");?

1) 55

2) 10

3) Error

4) None of the above

Answer : 55

Which of the following is used to define an indexer in C#?

1) public int this[int index] { get; set; }

2) public int Indexer(int index) { get; }

3) int this[int index];

4) None of the above

Answer : public int this[int index] { get; set; }

What is the output of Console.WriteLine(5 & 3);?

1) 1

2) 0

3) Error

4) None of the above

Answer : 1

Which of the following can be used to create a read-only property in C#?

1) public int MyProperty { get; }

2) public int MyProperty { set; }

3) public int MyProperty { get; set; }

4) None of the above

Answer : public int MyProperty { get; }

What is the output of Console.WriteLine(5 << 1);?

1) 10

2) 5

3) Error

4) None of the above

Answer : 10

Which of the following is true about delegates in C#?

1) They are type-safe function pointers.

2) They can only point to static methods.

3) They can have multiple return types.

4) None of the above

Answer : They are type-safe function pointers.

What is the output of Console.WriteLine(true && false);?

1) true

2) false

3) Error

4) None of the above

Answer : false

Which of the following statements is correct about properties in C#?

1) Properties can be defined with only get accessors.

2) Properties cannot have parameters.

3) Properties can only be auto-implemented.

4) None of the above

Answer : Properties can be defined with only get accessors.

What is the output of Console.WriteLine(10 / 3);?

1) 3

2) 3.33

3) Error

4) None of the above

Answer : 3