static class libraries?

G

Guest

hello. I'm new to making separate class libraries for my projects.

can you make a separate class library of a public static class ? with public
static methods ?

or is that not possible because in order to access a class library you need
to make an instance. what if you have the class library use the same
namespace as the current project ?

thanks
 
C

Chris Shepherd

Rogelio said:
hello. I'm new to making separate class libraries for my projects.

can you make a separate class library of a public static class ? with public
static methods ?

or is that not possible because in order to access a class library you need
to make an instance. what if you have the class library use the same
namespace as the current project ?

thanks

An assembly can contain static classes and methods just fine. I do it
all the time for helper methods.

Chris.
 
M

Morten Wennevik [C# MVP]

hello. I'm new to making separate class libraries for my projects.

can you make a separate class library of a public static class ? with public
static methods ?

or is that not possible because in order to access a class library you need
to make an instance. what if you have the class library use the same
namespace as the current project ?

thanks

Hi Rogelio,

A class library can contain only static classes just fine.

Sharing namespace across various projects (including libraries) works fine as well, although you may want to rethink your naming convention with perhaps a shared root namespace, sub namespaces.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top