ARTICLE

How to add reusable codes in Visual Studio Toolbox

Posted by Suthish Nair Articles | Visual Studio 2010 February 26, 2011
This article shows how to use the Visual Studio Toolbox to make reusable code available to any project.
Reader Level:

This article shows how to use the Visual Studio Toolbox to make reusable code available to any project.

Introduction

What do we do when we want to use a common set of logic code snippets in every page of a project? 
Usually we create a class library, create a .dll file or add a class file, create it and reference it from there. 
Another important and cool way which can be used in Visual Studio is to add or use code snippets 
into Toolbox tabs. Then later just drag and drop the item into your project page.


Lets' Start

In my project, I wanted to use code snippets shown below in multiple pages. This a simple method which returns a string type. 

I don't want to copy and paste or create a separate class file or a .dll file etc.. 

So, how will I use this code snippet on other pages?

public string hello() { return "www.c-sharpcorner.com"; }

It's simple; just select the method then drag and drop into the Toolbox tabs and a new item gets created. 

This item can be renamed, deleted or added with others like it.


1.jpg


This is another cool feature provided in Visual Studio, great!

Note: For every Visual Studio version you need to add this functionality everytime.


Conclusion

Hope this feature helps you in your daily coding ways. Post your comments.
 

Login to add your contents and source code to this article
post comment
     

Good to know suthish:)

Posted by Bala Jan 22, 2013

Great one!!!

Posted by Amol Apr 16, 2012

Nice Article:-)

Posted by Vijai Anand Feb 27, 2011
COMMENT USING
PREMIUM SPONSORS
Over-C is a holistic consortium of communications and technology specialists. We build, deploy and market both business as well as consumer products and solutions.
Get Career Advice from Experts
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Get Career Advice from Experts