add module vs add class??

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Greeting,
I'm still grasping the class concept so bear with me.
I have a vb.net app in which I wrote and placed various public functions for later reference.

In vb.net there is an option to "add class" or "add module". My understanding is a module is a class so what is the difference?

Correct me if I'm wrong....a module allows you to call various functions/procedures without first defining and class you do?
 
A module is a class, it's just a sealed (ie, you can't inherit from it) and
it has shared/static members. You can create a class that gives you the
same functionality (in C# modules as such don't exist) so the distinction
isn't really there. If you have a class with all shared members, you never
instantiate it so everything is shared or static. Very handy for some apps,
not quite so useful in others.

If you want to see what's really happening, create a class that's sealed and
mark everything static. Then create a module with the same names. Compile
and look at them through ILDASM...the similarities are remarkable.

HTH,

Bill
Ray said:
Greeting,
I'm still grasping the class concept so bear with me.
I have a vb.net app in which I wrote and placed various public functions for later reference.

In vb.net there is an option to "add class" or "add module". My
understanding is a module is a class so what is the difference?
Correct me if I'm wrong....a module allows you to call various
functions/procedures without first defining and class you do?
 
Thanks for the Reply William.

So it seems that in most cases, one would use add class as oppose to add module.

I'm slowly grasping the concept. From reading other threads there's no performance degregation in using a class vs module.

Since modules don't exist in C#, obviously use class.
But what scenario would I use module in VB as oppose to a Class?

Thanks for educating me!
 
Back
Top