Reputation: 41
I wanted to know if it is possible to reuse a class I created in one application in another application.
Basically I created a test program and once I got all the components working I created a class for it and well I want to use the class in another program, how can I do this?
I'm a nub when it comes to programming so if you can make it as easy to understand a possible I would be greatful.
Upvotes: 2
Views: 2150
Reputation: 218828
There are a couple of common ways, depending on how you want to organize your code/projects:
(1) is my personal preference, I like to have many projects in my solutions which reference each other's code directly rather than referencing compiled DLLs. A lot of people prefer (2) for their own code, not wanting to keep so many projects open all over the place and rather deal with a one-time compiled DLL. It's a matter of personal preference.
Upvotes: 4
Reputation: 100567
Your best bet is to have that class in an assembly.
Make a new project - a Windows Class Library. Put your class to be re-used in there.
Reference this project or built assembly from your application(s).
You'll be able to then Imports
the namespace in your consuming applications. Naming becomes important here, but try it out, and see how it works for you.
Upvotes: 1