By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,708 Members | 1,468 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,708 IT Pros & Developers. It's quick & easy.

How do you create a library of commonly used structs, enumerationsconstants and functions using C#

P: n/a
Coming from a pure C/C++ background - recently started looking at C# for
a project. The absence of header files in C# has thrown me "a bit of a
curve".

I want to modularise my code and put all the commonly used data types
etc into a single compilation unit (library). How may I do this in C# -
any examples would be useful - tx
Feb 4 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Bit Byte <ro**@yourbox.comwrote:
Coming from a pure C/C++ background - recently started looking at C# for
a project. The absence of header files in C# has thrown me "a bit of a
curve".

I want to modularise my code and put all the commonly used data types
etc into a single compilation unit (library). How may I do this in C# -
any examples would be useful - tx
Just create a class library project, and then add a reference to it
from other projects.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Feb 4 '07 #2

P: n/a
On Feb 4, 4:06 am, Bit Byte <r...@yourbox.comwrote:
Coming from a pure C/C++ background - recently started looking at C# for
a project. The absence of header files in C# has thrown me "a bit of a
curve".

I want to modularise my code and put all the commonly used data types
etc into a single compilation unit (library). How may I do this in C# -
any examples would be useful - tx
C# uses DLLs the way that C++ would use header files. The compiler
examines the contents of a DLL, part of which is a manifest that
contains definitions for all of the publicly available types,
including method call signatures.

So, just create a separate project for your common library, put all of
your common stuff in it, and build it into a DLL.

Then, when you want to use it in another project, just use Add
Reference in that project to add a reference to the DLL that you
created in the library project. Your client project will then "know
about" all of the public types in the library.

Feb 4 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.