2

I have the following error :

The name 'var' does not exist in the current context

on this method call :

myClient.GetCurrentPadding(out var currentPadding);

what can possibly be the problem? I've tried to update the microsoft.net.compilers nugget but in vain

Mehdi Souregi
  • 3,153
  • 5
  • 36
  • 53

1 Answers1

2

The out var is correct and is available if you use at least C# 7.0.

This is what the documentation tell about that feature called out variables.

So you need to make sure your project is configured to use at least C# 7 feature by following what is explained in this link.

This is what is explained by the link:

Right-click on the project node in Solution Explorer and select Properties. Select the Build tab and select the Advanced button. In the dropdown, select the version. The following image shows the "latest" setting:

enter image description here

CodeNotFound
  • 22,153
  • 10
  • 68
  • 69