Learn C# .Net MCQs

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

What is the output of Console.WriteLine(Math.Sqrt(25));?

1) 5

2) 6

3) 25

4) None of the above

Answer : 5

Which of the following is used to concatenate two strings in C#?

1) Concat()

2) Append()

3) Add()

4) None of the above

Answer : Concat()

Which of the following is used to pause the execution of a thread in C#?

1) Thread.Sleep()

2) Thread.Pause()

3) Thread.Stop()

4) None of the above

Answer : Thread.Sleep()

What is the correct way to handle an exception in C#?

1) try-catch

2) catch-finally

3) try-finally

4) None of the above

Answer : try-catch

Which of the following is the correct way to declare an array in C#?

1) int[] arr = new int[5];

2) int arr[5];

3) int arr[] = new int[5];

4) None of the above

Answer : int[] arr = new int[5];

Which of the following is true about the "sealed" keyword in C#?

1) It prevents inheritance.

2) It allows overriding.

3) It allows method overloading.

4) None of the above

Answer : It prevents inheritance.

Which of the following is the correct syntax for a foreach loop in C#?

1) foreach(int i in arr)

2) for(int i in arr)

3) for arr in i

4) None of the above

Answer : foreach(int i in arr)

Which of the following is used to get the length of a string in C#?

1) Length

2) Size

3) GetLength()

4) None of the above

Answer : Length

What is the output of Console.WriteLine("C#".ToLower());?

1) C#

2) c#

3) Error

4) None of the above

Answer : c#

Which of the following is used to check the type of a variable in C#?

1) is

2) typeof

3) instanceof

4) None of the above

Answer : is