Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 624
Venkat Avatar asked Dec 23 '15 10:12

Venkat


People also ask

What is go to implementation in Visual Studio?

Navigate to implementation of a type or a type member Choose Navigate | Go To Implementation in the main menu, press Ctrl+F12 , or click the symbol while holding Ctrl+Alt keys. Note that in Visual Studio 2017 and later, the Ctrl+Alt -click is used for adding multiple carets.

How do you enter method implementation in Visual Studio code?

Go to Implementation# Languages can also support jumping to the implementation of a symbol by pressing Ctrl+F12. For an interface, this shows all the implementors of that interface and for abstract methods, this shows all concrete implementations of that method.

What is peek definition in Visual Studio?

You can use the Peek Definition command to view and edit code without switching away from the code that you're writing. Peek Definition and Go To Definition show the same information, but Peek Definition shows it in a pop-up window, and Go To Definition shows the code in a separate code window.

How do we see implementation?

Navigate to implementation of a type or a type memberPress Ctrl+F12 or choose Navigate | Implementation(s) from the main menu . Alternatively, you can press Ctrl+Shift+A , start typing the command name in the popup, and then choose it there.


1 Answers

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.

like image 140
Hamid Mosalla Avatar answered Sep 23 '22 22:09

Hamid Mosalla