Link to home
Start Free TrialLog in
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?
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial