Re: Class vs. DLL



Paolo wrote:
Learning C# using Console applications. I want to develop some utility functions (wrapping up some of the Console class methods) so that I can have them available for any program that I write.

If I create a DLL do I include these functions by adding it as a reference in my projects?

If I create a Class do I add the 'using' directive to include them?

Are there any pros/cons with respect to either approach?

Thanks

You can create a new project in the solution and create one or more classes in it. This will then be compiled into a separate dll. To use the classes from the application you need to add a reference to the project.

To use the classes in another solution, you can either add the project to the solution and add a reference to the project, or add a reference to the compiled dll file.

(Of course you can also develop the project separately in it's own solution.)

If a class is in a different namespace (which it usually would be if it's in a separate project), you either can use a using directive to import the namespace or specify the full class name (i.e. namespace.classname) everytime you use the class.

--
Göran Andersson
_____
http://www.guffa.com
.



Relevant Pages

  • Re: C++ Mixed mode CLI problem/query
    ... > achieve that I have created a mixed mode DLL in which my unmanaged class ... > reference them through code, the namespace of the DLL is not ... > namespace is identified BUT the contained objects are not... ...
    (microsoft.public.dotnet.languages.vc)
  • Referencing a multifile assembly
    ... I then bundled these .netmodules files into a dll. ... Now I create a new project and add a reference to the dll I just ... namespace in which both classes are. ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Help, cant reference new dll?????????
    ... The new classes do not have to be in a different namespace, ... >> In VS 6.0 it was easy to create a new dll, compile it, and all the vb ... >> I want to reference this new dll and it's class/functions in my ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Class vs. DLL
    ... This will then be compiled into a separate dll. ... the classes from the application you need to add a reference to the project. ... import the namespace or specify the full class name (i.e. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Reference Callers Application Variables from DLL
    ... If you are not able to see nsGlobal in Intellisense, there may be a root namespace for the DLL that you are omitting. ... In the winforms project I have a reference to a separate DLL project. ...
    (microsoft.public.dotnet.framework.windowsforms)