const in .cs

  • Thread starter Thread starter stef
  • Start date Start date
S

stef

Hello

I would like to use const declaration in the same manner as C does (in
a .h file)
How can I do that ?

For now, I declare a class which contains only all my const
declarations... but sounds bad :(

Do you have any ideas ?


thanks...
 
I would like to use const declaration in the same manner as C does (in
a .h file)
How can I do that ?

For now, I declare a class which contains only all my const
declarations... but sounds bad :(

Do you have any ideas ?

Group your constants by their natural area - so "Pi" naturally lives
in the "Math" class, whereas the minimum value of a double is in the
"Double" class etc.

Jon
 
Stef,

Generally speaking, you should declare your constants where they make
sense. If you have a constant that is particular to a class, you should
declare it with that class, and not with a separate class just for
constants. Context is important here, I believe.

C# does not have the concept of a header file. If you need to use a
constant that is defined in a class in another assembly, then you need to
reference that assembly.

Hope this helps.
 

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

Back
Top