In C#, what is required of a parameter declared with the out keyword?
A
It is read-only inside the called method
B
It must be initialised by the caller before the call
C
It can only be used with value types, not classes
D
It must be assigned inside the method before returning
Correct answer
Correct answer
D. It must be assigned inside the method before returning
16 views
⚔️
Challenge a friend on C#
Same MCQs, timed, live leaderboard. Send the link on WhatsApp – no sign-up needed.
Create challenge
Explanation
An out parameter must be assigned by the method, but the caller does not need to initialise it. A ref parameter must be initialised by the caller, and an in parameter is read-only.
Reference
Asked in: NTS, Technical Interviews
Doubts & discussionNot sure why the answer is D? Ask here and get an explanation.
Ask a doubt about this MCQ
‹ Previous MCQ Which keyword defines an event in C#? Next MCQ › Which C# keyword declares a local variable whose type is inferred by the compiler at compile time?