I use C# to test my VB.Net assemblies. So today I got this little errormessage when doing this.
Here is the VB.Net method.
vbnet
''' <summary>
Public Sub SetFiberGroup(ByRef FiberGroup As FiberGroup)
_FiberGroup = FiberGroup
End Sub
I don’t use ByRef all that often but this time it was needed.
And normally you would call this like this in VB.Net.
vbnet
dim _FiberGroup as new FiberGroup
_obj.SetFiberGroup(_FiberGroup)
Or something like that. No different then setting a ByVal parameter.
So I would expect C# to act the same. But it doesn’t.
C# needs the ref keyword. like this
vbnet
var _FiberGroup = new FiberGroup();
_obj.SetFiberGroup(ref _FiberGroup);
If you don’t use the ref keyword then you need to get this little gem of an error.
Argument is ‘value’ while parameter is declared as ‘ref’
So the solution is simple and logical. But I just wrote this in case anybody else bumps into this because Google doesn’t seem to find that specific errormessage. Perhaps Yahoo will or Microsoft search but who uses those anymore.