9

Had a search and can't find this.

I'm looking for the VB.Net equivalent of C#7 inline out variable declaration, e.g:

MethodCall(arg1, out string arg2);

Does such a thing exist in the equivalent VB.Net versions?

* the duplicate proposed isn't quite right I'm afraid, but I've marked Heinzi's answer correct.

James Harcourt
  • 6,017
  • 4
  • 22
  • 42
  • 3
    According to [this post](https://www.codeguru.com/columns/vb/whats-new-in-visual-basic-15.html) this wasn't included in VB 15 so there's no equivalent yet – Camilo Terevinto Aug 16 '18 at 12:49
  • 1
    In VBnet you have ByValue and ByRef. So ByRef is the closest to out. – jdweng Aug 16 '18 at 12:59
  • 1
    Possible duplicate of [Is there a VB.NET equivalent of C# out parameters?](https://stackoverflow.com/questions/4358742/is-there-a-vb-net-equivalent-of-c-sharp-out-parameters) – Bouke Aug 16 '18 at 13:20
  • 2
    @Bouke: It's not a duplicate: The question you linked to asks about out parameters in general, this one asks about *inline variable declaration*, i.e., the `string` part of `out string arg2`. – Heinzi Aug 16 '18 at 13:23
  • 3
    To most of the commentators (except Camilo & Heinzi): Read the post! The C# code example is a method call which is declaring the 'out' variable right there where it's used. – Dave Doknjas Aug 16 '18 at 13:46
  • 3
    @jdweng I think you missed the point of the question ... it's not about passing arguments by reference or value - or about finding an equivalent to out parameters, but about the _inline declaration_ available in C#7. – James Harcourt Nov 22 '18 at 15:05

1 Answers1

9

This feature has been suggested to the Visual Basic language team:

but it is currently not implemented.

Heinzi
  • 167,459
  • 57
  • 363
  • 519