Goto定义和Visual Studio中的Goto实现之间的区别 [英] Difference between Goto Definition and Goto Implementation in Visual Studio
问题描述
在Visual Studio中Go To Definition
和Go To Implementation
有什么区别?
What is the difference between Go To Definition
and Go To Implementation
in Visual Studio?
版本::Visual Studio 2015更新1
Version: Visual Studio 2015 Update 1
推荐答案
假设我们具有以下接口:
Let's say we have this interface:
public interface IEmailSender
{
Task SendEmailAsync(string email, string subject, string message);
}
还有一个实现此接口的类:
And a class that implements this interface:
public class AuthMessageSender : IEmailSender
{
public Task SendEmailAsync(string email, string subject, string message)
{
// Plug in your email service here to send an email.
return Task.FromResult(0);
}
}
如果我们右键单击IEmailSender
并选择转到实现",Visual Studio会将我们导航到实现此接口的类,即AuthMessageSender
.
如果我们在AuthMessageSender
类中时右键单击IEmailSender
并选择转到定义",Visual Studio会将我们导航到IEmailSender
的定义.
If we right click on IEmailSender
and choose Go To Implementation, Visual Studio navigates us to the class that implements this interface, namely AuthMessageSender
.
If we right click on IEmailSender
while we are in AuthMessageSender
class and
choose Go To Definition, Visual Studio navigates us to the definition of the IEmailSender
.
这篇关于Goto定义和Visual Studio中的Goto实现之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!