Learn C# .Net MCQs

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

What is the output of Console.WriteLine("Hello, World!".Substring(0, 5));?

1) Hello

2) Hello,

3) World

4) None of the above

Answer : Hello

Which of the following is a way to read user input in C#?

1) Console.ReadLine();

2) Input.Read();

3) Console.Input();

4) None of the above

Answer : Console.ReadLine();

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

1) 22

2) 4

3) Error

4) None of the above

Answer : 22

Which of the following methods is used to sort a list in C#?

1) List.Sort();

2) List.OrderBy();

3) List.Arrange();

4) None of the above

Answer : List.Sort();

What is the output of Console.WriteLine(Math.Abs(-10));?

1) 10

2) -10

3) Error

4) None of the above

Answer : 10

Which of the following is used to convert a string to an integer in C#?

1) Convert.ToInt32()

2) int.Parse()

3) Both Convert.ToInt32() and int.Parse()

4) None of the above

Answer : Both Convert.ToInt32() and int.Parse()

What is the output of Console.WriteLine(4 * 2 - 8 / 4);?

1) 8

2) 6

3) 4

4) None of the above

Answer : 6

Which of the following is a way to declare an event in C#?

1) public event EventHandler MyEvent;

2) public EventHandler MyEvent;

3) MyEvent public event;

4) None of the above

Answer : public event EventHandler MyEvent;

What is the output of Console.WriteLine(5 + 2 * 3 - 1);?

1) 10

2) 11

3) 9

4) None of the above

Answer : 10

Which of the following is used to exit a method in C#?

1) exit;

2) return;

3) break;

4) None of the above

Answer : return;