Learn C# .Net MCQs

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

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

1) false

2) true

3) Error

4) None of the above

Answer : true

Which of the following is a loop structure in C#?

1) for

2) if

3) switch

4) None of the above

Answer : for

What does the "new" keyword do in C#?

1) Creates a new instance of an object.

2) Defines a constant.

3) Creates a new class.

4) None of the above

Answer : Creates a new instance of an object.

Which of the following methods can be used to compare two strings in C#?

1) String.Compare()

2) String.Equals()

3) Both of the above

4) None of the above

Answer : Both of the above

What is the output of Console.WriteLine(3 == 3 ? "True" : "False");?

1) False

2) True

3) Error

4) None of the above

Answer : True

Which of the following collections allows duplicates in C#?

1) Dictionary

2) HashSet

3) List

4) None of the above

Answer : List

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

1) 5

2) Error

3) None of the above

4) 5

Answer : Error

What is the purpose of the "using" directive in C#?

1) To import namespaces

2) To define constants

3) To create variables

4) None of the above

Answer : To import namespaces

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

1) HelloWorld

2) Hello World

3) Error

4) None of the above

Answer : Hello World

Which of the following is not a C# data type?

1) int

2) decimal

3) float

4) text

Answer : text