Venkat
Venkat

Reputation: 2579

Difference between Goto Definition and Goto Implementation in Visual Studio

What is the difference between Go To Definition and Go To Implementation in Visual Studio?

Version: Visual Studio 2015 Update 1

Upvotes: 25

Views: 7086

Answers (1)

Arman Hamid Mosalla
Arman Hamid Mosalla

Reputation: 3355

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);
    }
}

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.

Upvotes: 24

Related Questions