Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#: can 'out' parameters in functions be object properties/variables? [duplicate]

C#: can 'out' parameters in functions be object properties/variables?

eg:

can I call a function as follows:

someFunction(x, y, out myObject.MyProperty1)
like image 853
CJ7 Avatar asked Aug 06 '10 08:08

CJ7


1 Answers

Properties are [a pair of get and set] methods with a cute syntax for invoking them that makes them look like fields.

Out parameters can be references to fields or stack based 'fields' (i.e., locals).

The bridging of this gap is generally not addressed by languages (and definitely not directly by the CLR and IL model). (+1 on @Heinzi for the VB trickery references)

like image 173
Ruben Bartelink Avatar answered Oct 12 '22 22:10

Ruben Bartelink