Can anyone tell me what is VisualStudio 2017 trying to tell me with that grey ellipsis below keyword?
Neither placing the mouse over it or right-clicking it tells me why is this symbol showing there.
(gray ellipsis below "TValue" on the first line of the method)
There's a code suggestion/refactoring hidden there telling you that what you have written can also be written in some other form while achieving the same functionality.
Till C# 7 i.e. VS 2017, this was the way of writing that but with C#7 inline outs you can reduce it to
return TryGetValue(key, out TValue value) ? value : defaultValue;
You can also declare it var
which was not possible earlier. So you can write this as
return TryGetValue(key, out var value) ? value : defaultValue;
How to achieve this
Take your cursor to ...
and can see this suggestion in two ways
Ctrl
+ .
It's a hint. Place your cursor on it, give it a second or two, and you should see a Roslyn lightbulb appear.
In this case, it's probably trying to show you that C# 7 syntax will allow you to declare out variables inline:
this.TryGetValue(key, out TValue value) ? value : defaultValue;
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