C# and .NET step by step with interview questions
Showing posts with label visual studio. Show all posts
Showing posts with label visual studio. Show all posts
Sunday, January 22, 2012
Visual studio and .NET tips and tricks 14:- Implement interfaces with just a right click
Monday, September 26, 2011
.NET interview questions: - How to add a code snippet in Visual Studio 2010?
Visual Studio has two types of snippets namely Expansion snippet which are inserted at the cursor and SurroundsWith snippet which wraps around existing code.
Let’s see a small and simple example to understand it in better manner.
In order to see it practically just follow the following steps.
Step1: - create a new project of Console Application for that just go to >> File >> New >> Project >> Windows >> Select Console Application.


Step2: - Add XML file in your project for that just go to >> Solution
Explorer >> Right Click on the project name >> Add >> Add
New Item >> Select XML File.

Note: - Please save the XML File with .snippet extension like below diagram.

Step3: - Now just right click on code editor window and select the menu item Insert snippet or Press Ctrl + K + X and click the item Snippet like below diagrams.


As soon as you select Snippet the following tags will be automatically to the code editor window like below diagram.

Step4: - Just remove the tag below as we are creating an Expansion snippet.
Step5: - Now we have to load the snippet in the Visual Studio for that we have to use Code Snippet Manager which comes under Tools menu like below diagrams.
Go to >> Tools >> Customize >> Commands >> Tools >>
Add Command >>Select Code Snippet Manager.


Step6: - Now simply just save the file (MyCodeSnippet.snippet) to your desired location like below diagram.


Step7: - Now just simply open the code snippet manager and click on Import like below diagram.



Step8: - Now just simply open the program.cs file of console application and just add the created snippet in the code like below diagram.
Just right click on the code to add the snippet.


Now you will see that snippet is now being added to the code like below diagram.

Similarly, you can test for the second method SurroundsWith.
Also view our video on CAS, evidence, permission set & code groups as follows: -

Avail from the link more interview questions and answers for .NET for preparation.
Regards,
Refer author’s other blog for complete Most asked .NET interview questions
Let’s see a small and simple example to understand it in better manner.
In order to see it practically just follow the following steps.
Step1: - create a new project of Console Application for that just go to >> File >> New >> Project >> Windows >> Select Console Application.
Step2: - Add XML file in your project for that just go to >> Solution
Explorer >> Right Click on the project name >> Add >> Add
New Item >> Select XML File.
Note: - Please save the XML File with .snippet extension like below diagram.
Step3: - Now just right click on code editor window and select the menu item Insert snippet or Press Ctrl + K + X and click the item Snippet like below diagrams.
As soon as you select Snippet the following tags will be automatically to the code editor window like below diagram.
Step4: - Just remove the tag below as we are creating an Expansion snippet.
<SnippetType>SurroundsWith</SnippetType> Now simply just make the necessary changes to the tags as I have done in below code snippet. <?xml version="1.0" encoding="utf-8" ?> <CodeSnippet Format="1.0.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <Header> <Title>CodeSnippetExample</Title> <Author>Feroz Shaikh</Author> <Shortcut>CodeSnippet</Shortcut> <Description>Add a Header to Code File</Description> <SnippetTypes> <!--<SnippetType>SurroundsWith</SnippetType>--> <SnippetType>Expansion</SnippetType> </SnippetTypes> </Header> <Snippet> <Declarations> <Literal> <ID>Author</ID> <Default>Feroz Shaikh</Default> </Literal> </Declarations> <Code Language="CSharp"> <![CDATA[ /**************** Code File Header ****************** Author: $Author$ Date: 26/09/2011 Version: 1.0.0.1 Description: Adding a header to the Code File ****************************************************/ ]]> </Code> </Snippet> </CodeSnippet>
Step5: - Now we have to load the snippet in the Visual Studio for that we have to use Code Snippet Manager which comes under Tools menu like below diagrams.
Go to >> Tools >> Customize >> Commands >> Tools >>
Add Command >>Select Code Snippet Manager.
Step6: - Now simply just save the file (MyCodeSnippet.snippet) to your desired location like below diagram.
Step7: - Now just simply open the code snippet manager and click on Import like below diagram.
Step8: - Now just simply open the program.cs file of console application and just add the created snippet in the code like below diagram.
Just right click on the code to add the snippet.
Now you will see that snippet is now being added to the code like below diagram.
Similarly, you can test for the second method SurroundsWith.
Also view our video on CAS, evidence, permission set & code groups as follows: -
Avail from the link more interview questions and answers for .NET for preparation.
Regards,
Refer author’s other blog for complete Most asked .NET interview questions
Saturday, September 24, 2011
C# interview questions :- How do you debug C# applications using Visual studio ?.
I use the following things for debugging c# applications using visual studio :-
1. Step over if we want to move one step after other.
2. Step in , if we want to move in to a function.
3. Step out , if we want to move out of the function.
4. Add watch and Quick watch to see the variable data.
5. Intellitrace to back trace debugging history.
Put the below link of the video

Get more materials on c# interview questions and answers
Regards,
Also see author’s other blog on Most asked c# interview questions
1. Step over if we want to move one step after other.
2. Step in , if we want to move in to a function.
3. Step out , if we want to move out of the function.
4. Add watch and Quick watch to see the variable data.
5. Intellitrace to back trace debugging history.
Put the below link of the video
Get more materials on c# interview questions and answers
Regards,
Also see author’s other blog on Most asked c# interview questions
5 tips to debug c# program using visual studio 2010 ( f10,11 watch windo...
for more .net and c# interview questions videos click on .NET and c# interview questions
Subscribe to:
Posts (Atom)