Sunday, August 10, 2014

Peek Definition VS Go To Definition in Visual Studio

In Visual Studio 2013 Microsoft added a very useful feature named peek definition. You will be amazed to see this feature because now you can change the code in another page without navigating away from the current screen you are in.
Suppose you are debugging in your code and you reached to a function where you find an error. Earlier you have to go to the .CS page where you function is defined and have to change the code. In those case we just right click over the function and use Go to Definition option to navigate to the exact function.

Now with Visual Studio 2013 you don’t need to navigate away from the page. Once you reach the function just press Alt+F12 to open the code used for that particular function in a small pop up. This is called peek definition. Other option would be to select the function you wanted to change and then right click and select peek definition.
Lets see the window of peek definition in visual studio 2013.
Here in the above screen print you can see that, I have highlighted the method I wanted to see and then right click and selected the Peek Definition. Once you select the Peek Definition then you will get below screen with a small pop up with the code used for that method. <Don’t look at the code as it was a demo application!!!>
I hope now you understood what exactly is Peek definition and how you can utilize this while coding and debugging.
Do you want me to explain what is Go to Definition now! I hope you all have been use this feature for years now. No difference from the above except the code used for the method will be opened from its original location.
Thank you for reading the article. Please write your comment below if you have any.

No comments: