Visual Studio中Goto定义与Goto实现的区别

时间:2015-12-23 10:39:50

标签: c# .net visual-studio visual-studio-2015 go-to-definition

Visual Studio中Go To DefinitionGo To Implementation之间有什么区别?

版本: Visual Studio 2015 Update 1

1 个答案:

答案 0 :(得分:10)

假设我们有这个界面:

public interface IEmailSender
{
    Task SendEmailAsync(string email, string subject, string message);
}

实现此接口的类:

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并选择Go To Implementation,Visual Studio会将我们导航到实现此接口的类,即AuthMessageSender
如果我们在IEmailSender课程中右键单击AuthMessageSender并选择转到定义,Visual Studio会将我们导航到IEmailSender的定义。< / p>