C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » C# Syntax »

Using class libraries in C#


Posted Date: 02 Nov 2009    Resource Type: Code Snippets    Category: C# Syntax
Author: Abhisek PandaMember Level: Gold    
Rating: 1 out of 5Points: 5



Creating and using an Assembly/Class Library



To create an assembly or class library in C# select class library project from new project window. Then clock on OK. A new code editor will be opened write the following code in it,


public class Demo
{
void show()
{
Console.WriteLine("Welcome to Class Library Project");
}
}


Now build the above class library and save it. Now create a new console application. Right click on the project name and click on "add reference". Then browse the class library you now created and add it to your console application.

Then write the following code to use the class library,

using Demo;//Implementing class library in our application
class MyProgram
{
static void Main(String args[])
{
//creating object of class library class
Demo d = new Demo();
//using the show method of the class library
d.show();
}
}



The output of the above console application will be "Welcome to Class Library Project". Similarly we can use class libraries in different languages of .NET. In VB.NET you have to use "import" instead of "using" to add the class library.



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Class Library  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Using winAPI in .NET Program
Previous Resource: Modify the web.config's value at runtime
Return to Discussion Resource Index
Post New Resource
Category: C# Syntax


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use