Question discussion

Which statement about the 'ref' and 'out' parameters in C# is correct?

1170Medium DSSSB TGT Computer Science 0 replies 1 views
0

Which statement about the 'ref' and 'out' parameters in C# is correct?

  • AAn argument passed with ref must be initialised before the call, but one passed with out need not be
  • BBoth ref and out arguments must be initialised before the call
  • CAn out argument must be initialised before the call, but a ref argument need not be
  • DNeither ref nor out can be used with value types
Correct answer: A

Explanation

ref requires an already-initialised variable, while out only requires the method to assign the variable before returning.

Discussion 0

Nobody has replied yet. Start the discussion!