The thing you are passing as ref
is:
Arg<Line.EligibleType>
.Ref(brBD.Line.EligibleType, Line.EligibleType.skipNone).Dummy
Now; we can't see Arg<T>.Ref
, but I'm guessing it returns a class upon which .Dummy
is a property. In C# you can't pass a property as a ref
. I imagine VB elects to spoof this, essentially doing the equivalent of:
var tmp = Arg<Line.EligibleType>.Ref(brBD.Line.EligibleType, Line.EligibleType.skipNone).Dummy;
return s.Eligible(ref tmp)
However, C# chooses not to work this way. IIRC, VB also allows ref
to be implicit, so there are some very different design aims around how ref
should be treated.
But I have to agree with C# - in the ref
usage, you aren't really passing a "reference to the property", so for me at least, it avoids incorrect usage to work the way it does - even if that is more explicit.
As an aside: if .Dummy
was a field, then you can pass it as ref
; however, this should not be interpreted as "make .Dummy
a field"; that is very much not what I said ;p
I understand the error. You can’t pass an enumeration by reference because an enumeration is a constant and can’t be assigned.
You can pass references to fields, references to local variables / parameters, and references to things in array as ref
; those things can be typed as enumerations.