Bring enough .NET developers together and sooner or later someone will start the discussion if we should use the ‘var’ keyword or not.
You have people in the ‘pro’ camp who like that they have to type less and don’t worry too much about the specific type. You have people in the ‘contra’ camp who prefer to have explicit typing.
In Visual Studio 2022, you can get the best of both worlds by enabling ‘inline hints hints’. Inlay hints can display parameter name hints for literals, function calls and more.
- To enable this feature, go to Tools > Options > Text Editor > C# or Basic > Advanced.
- Check the ‘Display inline parameter name hints’ checkbox
- Check the ‘Display inline type hints’ checkbox
Now we can see that both our arguments and the var types are annotated: