Topic / 95 questions

C# MCQs

Page 3 of C# multiple-choice questions with answers. Tap an option to check yourself.

Page 3 of 5

Question 41 C#

What is a delegate in C#?

Correct answer D. A type-safe reference to a method with a specific signature

Open question
Question 42 C#

What does the C# using statement guarantee for an object such as a StreamReader?

Correct answer A. Its Dispose method is called when the block is exited, even if an exception is thrown

Open question
Question 43 C#

What is a local function in C#?

Correct answer C. A method declared inside another method and visible only within it

Open question
Advertisement
Question 44 C#

When does a static constructor run in C#?

Correct answer B. Once, automatically, before the first instance is created or any static member is accessed

Open question
Question 48 C#

What is a key difference between a class and a struct in C#?

Correct answer A. A class is a reference type, while a struct is a value type copied on assignment

Open question
Question 49 C#

Which requirement applies to declaring an extension method in C#?

Correct answer A. It must be a static method in a non-generic static class, with this before the first parameter

Open question
Advertisement
Advertisement
Question 57 C#

Which statement about the C# switch statement is true?

Correct answer D. Control cannot fall through from one non-empty case section to the next

Open question
Question 59 C#

What does the property pattern s is { Length: > 3 } test in C#?

Correct answer B. That s is not null and its Length property is greater than 3

Open question