Posts C# "out" modifier -> HowTo in VB.NET?
Post
Cancel

C# "out" modifier -> HowTo in VB.NET?

Someone on GDN asked a question regarding the out parameter modifier that C# uses and how to do the same thing in VB.NET.

Your first guess would probably be to use ByRef, however, ByRef is like ref in C#; so that isn't the answer.  The real answer is to use the <out()></out()> attribute (also note, there is the <in()></in()> attribute as well).

The out parameter modifier is used when working with COM interop and platform invoke.  It has to do with the way that the marshalling layer moves (or lack of) the variable during the call.  For more information, be sure to take a look at the OutAttribute Class documentation on MSDN.

Thanks to Duncan Mackenzie for providing the information.

This post is licensed under CC BY 4.0 by the author.