I am trying to use the 'out parameter' within a .NET 4.5.2 application, but I am getting a compile error.
Questions: In which framework can I compile this? What does this called? Inline variable declaration in out method calling?
Could you please provide a reference?
Ref: https://www.dotnetperls.com/parse
new out syntax: We can place the "out int" keywords directly inside a method call. Older versions of C# do not allow this syntax. But this can reduce the line count of a program.
static void Main()
{
const string value = "345";
// We can place the "out int" declaration in the method call.
if (int.TryParse(value, out int result))
{
Console.WriteLine(result + 1);
}
}
This requires C# version 7 that ships with Visual Studio 2017.
The feature is called "Out Variables".
In C# 7.0 we have added out variables; the ability to declare a variable right at the point where it is passed as an out argument:
public void PrintCoordinates(Point p) { p.GetCoordinates(out int x, out int y); WriteLine($"({x}, {y})"); } }
Further documentation can be found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With