admin管理员组文章数量:1122846
Let's take the example:
var myObject = GetCustomer(1234);
Where GetCustomer
retrieves an object which is representative of a customer with the class myClass
.
Is there a quick way in VS2022 to navigate to the declaration of myClass
either through the mouse, keyboard or menu?
If I right-click on myObject, I get a number of items which pop up. I've tried "Go to Declaration", "Navigate To...", "Go to Definition", "Go to base", "Go to Implementation", none of them take me to where myObject is actually declared (not sure why "go to declaration" doesn't work, it takes me to the first time the variable is used in the current function).
As a bonus, I do have reSharper also installed, so perhaps a way to do it in there, but I don't see anything.
Let's take the example:
var myObject = GetCustomer(1234);
Where GetCustomer
retrieves an object which is representative of a customer with the class myClass
.
Is there a quick way in VS2022 to navigate to the declaration of myClass
either through the mouse, keyboard or menu?
If I right-click on myObject, I get a number of items which pop up. I've tried "Go to Declaration", "Navigate To...", "Go to Definition", "Go to base", "Go to Implementation", none of them take me to where myObject is actually declared (not sure why "go to declaration" doesn't work, it takes me to the first time the variable is used in the current function).
As a bonus, I do have reSharper also installed, so perhaps a way to do it in there, but I don't see anything.
Share Improve this question edited Nov 21, 2024 at 17:57 marc_s 754k183 gold badges1.4k silver badges1.5k bronze badges asked Nov 21, 2024 at 17:30 LarryBudLarryBud 1,07312 silver badges23 bronze badges 01 Answer
Reset to default 1If the return type of GetCustomer
is myClass
(so the type of myObject
is also myClass
), you can navigate to myClass
using either of these options:
- Hold Ctrl and click the
var
keyword. - Right-click the
var
keyword and click Go to Definition.
If GetCustomer
might return a subclass of myClass
, then you can right-click the var
keyword and click Go to Implementation to see a list of subclasses of myClass
.
版权声明:本文标题:c# - Is there a quick way to navigate to the underlying object of a variable in Visual Studio? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736308441a1933662.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论