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

Pre-processor directives

P: n/a
Can we have a pre-processor directive such as

#define LEN 132

in C# v1.1? If so, are there any restrictions as to the scope of such a

Apr 25 '06 #1
Share this Question
Share on Google+
2 Replies

P: n/a
Sathyaish wrote:
Can we have a pre-processor directive such as

#define LEN 132

No. The "pre-processor" is basically used for conditional compilation,
diagnostics and regions.

Instead, you should define a constant in a class, eg:

public class Something
public const int MaxLength = 132;

Note that there's a difference between a "const" and a static readonly
field - the value of a const is fetched at compile-time, so if you
change the value you'll need to recompile all the assemblies which used
it. A static readonly field would be fetched at runtime, so changes
will be picked up automatically.


Apr 25 '06 #2

P: n/a
Thanks very much indeed, Jon.

Apr 25 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.