Avatar of VBBRett
VBBRett

asked on 

How to implement your individual class into any project

I am fully aware of how to create a class and a namespace, you just declare it at the top of your class file.  But let's say that I had a project where I created a merchant namespace and a shopping cart class and I wanted to use that namespace and class in another project or solution, how would I go about doing it?
C#

Avatar of undefined
Last Comment
manishkungwani
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of starlite551
starlite551
Flag of India image

First of all, You need to compile your class file into a .dll or .exe assembly file. Whenever you build your code that is automatically done for you. And the output .dll or .exe is stored in Project\..\bin\debug folder. Now when you have a new project go to solution explorer. Then right click on project and click on Add Reference. Then Browse to your .dll or .exe file, select that file and click ok. Now you get a reference to your class inside the new project. Then in the code editor add a using statement at the top of your .cs code file using your_namespace; .Here your_namespace is the name of the namespace you previously created in which ur class file resides. Thats it.. Then simply start coding Create object of your class and move on..
Avatar of VBBRett
VBBRett

ASKER

Thanks starlite551.  If I wanted to copy all the dll files that I created and put them in a folder to hold all of my classes for future reference called My Programmed Classes, could I do that as opposed to sorting and looking through all of my project folders?  That way for future reference I don't have to recall what project I held a class in?
SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
C#
C#

C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).

98K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo