在代码中访问编译器常量 [英] Access Compiler Constants in code

查看:56
本文介绍了在代码中访问编译器常量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在下面的代码中使用由编译器定义的常量?

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

我正在运行批处理,但是我的一位客户数据遇到了问题。我只想为该客户添加特殊代码,但我想保留该代码,以便将来在需要调试其他客户时可以轻松切换客户ID。

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.

然后,已编译的dll的源代码将如下所示:

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

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


推荐答案

否编译器指令就是编译器指令。它们不包含在生成的IL代码中,因此无法在运行时访问。

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.

这篇关于在代码中访问编译器常量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆