Goto定义和Visual Studio中的Goto实现之间的区别 [英] Difference between Goto Definition and Goto Implementation in Visual Studio

查看:252
本文介绍了Goto定义和Visual Studio中的Goto实现之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio中Go To DefinitionGo 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆