VS 2005: how to use the same class.cs in two projects

  • Thread starter Thread starter Serdge Kooleman
  • Start date Start date
S

Serdge Kooleman

c# how to use the same class in two projects?



i have solution that consists of website, winapp and web service.

i need to use the same class MyClass.cs in all three applications.

i cannot figure out how to do in the VS 2005?
 
You'd have at least two choices. You can (a) compile the contents of the
MyClass.cs file into a Class Library project and then consume the assembly
from the other projects, or (b) when you add the file to a project you
should be able to select the "link file" option from the dropdown on the
"open" button - this would allow you to share (link) the file between other
projects.
 
Serdge Kooleman said:
i have solution that consists of website, winapp and web service.

i need to use the same class MyClass.cs in all three applications.

i cannot figure out how to do in the VS 2005?


Add a 4th project "BusinessStuff" to the solution. Put "Myclass.cs" into
that project.

Add a proiject reference from website, winapp, and webservice to the
BusinessStuff project.

Now, in any of those, just say, "BusinessStuff.MyClass mc;" and you're good
to go.
 
Back
Top