C# (Sharp) Programming Language Question:
Download Job Interview Questions and Answers PDF
Does C# support #define for defining global constants?
Answer:
No. If you want to get something that works like the following C code:
#define A 1
use the following C# code: class MyConstants
{
public const int A = 1;
}
Then you use MyConstants.A where you would otherwise use the A macro.
Using MyConstants.A has the same generated code as using the literal 1.
#define A 1
use the following C# code: class MyConstants
{
public const int A = 1;
}
Then you use MyConstants.A where you would otherwise use the A macro.
Using MyConstants.A has the same generated code as using the literal 1.
Download C# (Sharp) Programming Language Interview Questions And Answers
PDF
Previous Question | Next Question |
Is it possible to have different access modifiers on the get/set methods of a property? | Does C# support templates? |