1 year ago
#8708
Daniel
Compiler says variables declared within compiler directive doesnt exist
Suppose I have this code (all in the same class):
#if CONDITION
private static readonly string firstName = "First Name";
#endif
string GetName(){
#if CONDITION
return firstName;
#endif
return "Second Name";
}
It is giving me the error The name 'firstName' does not exist in the current context in the function GetName()
.
How can I fix this error?
c#
compiler-directives
0 Answers
Your Answer