Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access Compiler Constants in code

Is it possible to use a constant defined by the compiler in code like below?

#If DEALER_DEBUG = "ID12345" Then
        If(Dealer.ID = DEALER_DEBUG) Then
        'Do something
        End If
#End If

I'm running batch processes and I'm experiencing problems with one of my customer's data. I want to add special code for only that customer, but I want to keep the code there so I can easily switch the customer ID in the future should i need to debug a different customer.

The source-code of the compiled dll will then look like this:

        If(Dealer.ID = "ID12345") Then
        'Do something
        End If
like image 497
JD Stuart Avatar asked Aug 08 '26 16:08

JD Stuart


1 Answers

No. Compiler directives are just that, directives to the compiler. They are not included in the generated IL code, and so cannot be accessed at runtime.

like image 52
Chris Shain Avatar answered Aug 11 '26 11:08

Chris Shain



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!