Sunday, July 12, 2009

How do you create a packet/namespace/class library in C# Visual Studio?

I gots me a bunch of classes that I would like to be able to access by





using myClasses;





but I have no idea how to do this. I have done similiar things in Java but never with C#.

How do you create a packet/namespace/class library in C# Visual Studio?
create .cs (class) files from the file%26gt;new menu. this will create a class file using the default namespace of your project. you can then add all the methods and properties you want from existing code et.al. if you use the same namespace, you won't need to use a using statement. or you can create a brand new project with all your classes in it, then create a reference to that project from the solution explorer. good to put the project in the same solution as your main project. then use the using command just as you are wishing to in your question.
Reply:Change the project to compile as a DLL, and put that DLL somewhere global (e.g. besides the Debug folder)





Now create a new project, and add your DLL as a Reference (browse to it).





Now in your code you can do the using statement of your new library.


No comments:

Post a Comment