Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent of inline out parameter declaration?

Tags:

c#

vb.net

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.

like image 230
James Harcourt Avatar asked Aug 16 '18 12:08

James Harcourt


People also ask

What is inline variable declaration?

The new inline variable declaration syntax allows you to declare the variable directly in a code block (allowing also multiple symbols as usual): procedure Test; begin var I: Integer; I := 22; ShowMessage (I.

What is an out parameter in C?

An out-parameter represents information that is passed from the function back to its caller. The function accomplishes that by storing a value into that parameter. Use call by reference or call by pointer for an out-parameter. For example, the following function has two in-parameters and two out-parameters.

What is out _ in C#?

The out is a keyword in C# which is used for the passing the arguments to methods as a reference type. It is generally used when a method returns multiple values.

Do you need to declare an out variable before you use it in C#?

Variables passed as out arguments do not have to be initialized before being passed in a method call. However, the called method is required to assign a value before the method returns.


1 Answers

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

  • Proposal: inline variable declaration and assignment within expressions.

but it is currently not implemented.

like image 189
Heinzi Avatar answered Sep 22 '22 19:09

Heinzi