Tips and Tricks: C# Code Surround-with Snippets

Csharp
Csharp

Tips and Tricks: C# Code Surround-with Snippets

Welcome to CodeSpread!

We have discussed Code Snippets and one of the two types, expansion snippets in our previous article: Tips and Tricks: C# Code Expansion Snippets

Now, we will discuss Surround-with snippets.

Surround-with snippets are added around a selected block of code.

How to use Surround-with snippets?

Select the lines of code you want to surround with a snippet.


class CodeSpread

{

void printname()

{

Console.WriteLine(“CodeSpread”);

}

}

 

Now Either press CTRL + K, CTRL + S OR select one of the option from “Surround With” in Intellisense.

surround

surround

Here, if we select “if” snippet, then it will wrap the selected code snippet with the “if” statement.


class CodeSpread

{

void printname()

{

if(true)

{

Console.WriteLine(“CodeSpread”);

}

}

}

Is Surround-with feature available for front end?

Yes, it can be used in HTML markup also. Follow the same steps as above. With the help of this feature, you can surround the HTML markup with a snippet like “div” snippet, “form” snippet or more. Even in case of asp.net control, same steps can be used to surround the control with snippet like “Panel” snippet, “Repeater” snippet.

Isn’t it cool?

Author: hershey

A passion for knowledge drives me to do programming, A passion for programming drives me to create something different, A passion for creation drives me to spread the knowledge.

Share This Post On

0 Comments

  1. nice superb explaination

    Post a Reply
  2. thanks for the tutorial
    I am having a problem.
    The feature “Create SQL server database” isn’t available , I can’t select it.
    Can you help, please ?

    Post a Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

More from CodeSpread:

  • Tips and Tricks: C# Code Expansion SnippetsTips and Tricks: C# Code Expansion Snippets“Ever felt like not writing the same code again? Yes! But what is the solution? Solution is Code Snippets.” What is a Code Snippet? Code snippets are small blocks of reusable code which contain...
  • RegisterStartupScript, RegisterOnSubmitStatementRegisterStartupScript, RegisterOnSubmitStatementWe have discussed RegisterClientScriptBlock, RegisterClientScriptInclude in our previous article here. There are two more methods to client script dynamically from server side. We will discuss thes...
  • RegisterClientScriptBlock, RegisterClientScriptIncludeRegisterClientScriptBlock, RegisterClientScriptInclude"Current trends are more inclined towards the client model for a better UI experience where small pieces of client script are integrated into the application." These client scripts can be declarat...
  • Tip : Code Structure C#Tip : Code Structure C#As a developer, I always stress on developing a habit of following the best practices to structure the code. It helps me to easily navigate through the code and also saves a lot of effort in search...
  • IIS Pre-ArticleIIS Pre-ArticleI thought of sharing few articles on IIS so when I started my mission, I realized that there should be some basic tasks related to IIS which needs to be done by the user before diving deep into IIS...
  • C# Code to send a MailC# Code to send a MailWhile working in a project, we always neglect the importance of the code which we have written many times and now end up in copy pasting the code from old projects. Lately, I saw a request in fo...
  • Asp.Net: More about CookiesAsp.Net: More about CookiesWe have seen, how our cookies looks in our last article Cookies Part 1. In this article, we will talk about their properties,limitations and technical part. Properties and Limitations Cook...
  • Time Out: Not a Technical postTime Out: Not a Technical postTaking my time-out from technical world for once and sharing a regular joke in the form of  this comic with you. There is no harm in showing funny side also sometimes. wat say!!