【问题标题】:Difference between Goto Definition and Goto Implementation in Visual StudioVisual Studio 中 Goto 定义和 Goto 实现的区别
【发布时间】:2016-03-29 18:39:48
【问题描述】:

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

版本: Visual Studio 2015 Update 1

【问题讨论】:

  • 我能理解你的困惑。差异是微妙的。

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


【解决方案1】:

假设我们有这个接口:

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
如果我们在AuthMessageSender 类中右键单击IEmailSender
选择转到定义,Visual Studio 会将我们导航到IEmailSender 的定义。

【讨论】:

  • 简而言之:您定义一个接口,然后实现某个接口的类。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-12-18
  • 2010-12-15
  • 2023-04-02
  • 1970-01-01
  • 1970-01-01
  • 2023-03-25
  • 2020-02-16
相关资源
最近更新 更多