472,968 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,968 software developers and data experts.

Class vs. DLL

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
Aug 12 '08 #1
10 2034
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
Aug 12 '08 #2
As you are trying to do, it is always a good practice to move common
functionality away from the application so that it can be shared.

Now some clarification regarding your "class" vs. "dll" question. A DLL is
a container for classes, therefore when you create a class, it is compiled
into a DLL/Assembly. You can simply create another "library" project and
move your classes/code from the console project. Once done, then yes, you
have to add a reference to that assembly in your console application.

As to whether you use a "using" statement depends on your namespaces. If
your choose to give your library code a different namespace from your
application (which you will probably want to do since this code will be
shared) then you will also need to add a "using"directive in any application
file that references your utility classes.
"Paolo" <Pa***@discussions.microsoft.comwrote in message
news:96**********************************@microsof t.com...
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

Aug 12 '08 #3
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?
Not really.

The stuff in the DLL is made available not included.
If I create a Class do I add the 'using' directive to include them?
Not really.

The using allows you to refer to class names without their namespace.
Are there any pros/cons with respect to either approach?
You put compile one or more classes to a DLL. Good.

Arne
Aug 13 '08 #4
On Aug 13, 3:09*am, Paolo <Pa...@discussions.microsoft.comwrote:
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
As I see in your case, go for a DLL version of implementation. I see
that as a best practice.

-Cnu
Aug 13 '08 #5
Peter: thanks for the clear explanation, which clarifies my supplementary
questions regarding namespaces and adding references.

As I understand it, if I choose a 'Class Library' as my project this gets
compiles into a DLL.

"Peter Rilling" wrote:
As you are trying to do, it is always a good practice to move common
functionality away from the application so that it can be shared.

Now some clarification regarding your "class" vs. "dll" question. A DLL is
a container for classes, therefore when you create a class, it is compiled
into a DLL/Assembly. You can simply create another "library" project and
move your classes/code from the console project. Once done, then yes, you
have to add a reference to that assembly in your console application.

As to whether you use a "using" statement depends on your namespaces. If
your choose to give your library code a different namespace from your
application (which you will probably want to do since this code will be
shared) then you will also need to add a "using"directive in any application
file that references your utility classes.
"Paolo" <Pa***@discussions.microsoft.comwrote in message
news:96**********************************@microsof t.com...
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


Aug 13 '08 #6
Goran: thanks for the clarification.

"Göran Andersson" wrote:
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
Aug 13 '08 #7
Arne:
If I create a DLL do I include these functions by adding it as a reference
in my projects?

Not really.
How does the application 'know' about my functions?

"Arne Vajhøj" wrote:
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?

Not really.

The stuff in the DLL is made available not included.
If I create a Class do I add the 'using' directive to include them?

Not really.

The using allows you to refer to class names without their namespace.
Are there any pros/cons with respect to either approach?

You put compile one or more classes to a DLL. Good.

Arne
Aug 13 '08 #8
Cnu: VSC# Express allows a 'Class Library' project to be created - there is
no separate 'Create DLL' project type, so I presume a Class Library will be
compiled to a DLL.

Thanks

"Duggi" wrote:
On Aug 13, 3:09 am, Paolo <Pa...@discussions.microsoft.comwrote:
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

As I see in your case, go for a DLL version of implementation. I see
that as a best practice.

-Cnu
Aug 13 '08 #9
Peter: a further question. Do I have to make the member methods of my
'Utilities' class/DLL public so that applications which use them can 'see'
them?

"Peter Rilling" wrote:
As you are trying to do, it is always a good practice to move common
functionality away from the application so that it can be shared.

Now some clarification regarding your "class" vs. "dll" question. A DLL is
a container for classes, therefore when you create a class, it is compiled
into a DLL/Assembly. You can simply create another "library" project and
move your classes/code from the console project. Once done, then yes, you
have to add a reference to that assembly in your console application.

As to whether you use a "using" statement depends on your namespaces. If
your choose to give your library code a different namespace from your
application (which you will probably want to do since this code will be
shared) then you will also need to add a "using"directive in any application
file that references your utility classes.
"Paolo" <Pa***@discussions.microsoft.comwrote in message
news:96**********************************@microsof t.com...
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


Aug 13 '08 #10
Paolo wrote:
>>If I create a DLL do I include these functions by adding it as a reference
in my projects?
Not really.

How does the application 'know' about my functions?
Adding a reference does just that add a reference - it does not
include the functions.

Arne
Aug 13 '08 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Fernando Rodriguez | last post by:
Hi, I need to traverse the methods defined in a class and its superclasses. This is the code I'm using: # An instance of class B should be able to check all the methods defined in B #and A,...
18
by: John M. Gabriele | last post by:
I've done some C++ and Java in the past, and have recently learned a fair amount of Python. One thing I still really don't get though is the difference between class methods and instance methods. I...
1
by: Oplec | last post by:
Hi, I'm learning C++ as a hobby using The C++ Programming Language : Special Edition by Bjarne Stroustrup. I'm working on chpater 13 exercises that deal with templates. Exercise 13.9 asks for me...
13
by: Bryan Parkoff | last post by:
I have created three classes according to my own design. First class is called CMain. It is the Top Class. Second class and third class are called CMemory and CMPU. They are the sub-classes....
9
by: Banaticus Bart | last post by:
I wrote an abstract base class from which I've derived a few other classes. I'd like to create a base class array where each element is an instance of a derived object. I can create a base class...
8
by: Bryan Parkoff | last post by:
I find an interesting issue that one base class has only one copy for each derived class. It looks like that one base class will be copied into three base classes while derived class from base...
21
by: Jon Slaughter | last post by:
I have a class that is basicaly duplicated throughout several files with only members names changing according to the class name yet with virtually the exact same coding going on. e.g. class...
5
by: Andy | last post by:
Hi all, I have a site with the following architecture: Common.Web.dll - Contains a CommonPageBase class which inherits System.Web.UI.Page myadd.dll - Contains PageBase which inherits...
3
by: Hamilton Woods | last post by:
Diehards, I developed a template matrix class back around 1992 using Borland C++ 4.5 (ancestor of C++ Builder) and haven't touched it until a few days ago. I pulled it from the freezer and...
0
by: emin.shopper | last post by:
I had a need recently to check if my subclasses properly implemented the desired interface and wished that I could use something like an abstract base class in python. After reading up on metaclass...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.