Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VisualStudio 2017 gray ellipsis below keyword

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.

VisualStudio2017 code image (gray ellipsis below "TValue" on the first line of the method)

like image 974
Marcelo Myara Avatar asked May 07 '17 14:05

Marcelo Myara


2 Answers

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

  1. Press Ctrl + .
    OR
  2. A roslyn bulb will appear and you can click on it and the drop down will suggest you the same.
like image 75
Nikhil Agrawal Avatar answered Nov 11 '22 16:11

Nikhil Agrawal


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;
like image 27
Austin Drenski Avatar answered Nov 11 '22 17:11

Austin Drenski