VB.NET Turning Option Strict Off In-Line

前端 未结 3 1288
暖寄归人
暖寄归人 2020-12-18 19:10

Is there a way to turn option strict off for just a single line of code?

I\'m doing some maintenance work and I need to \"cheat\" in just one place and I don\'t wa

3条回答
  •  感动是毒
    2020-12-18 19:53

    Sadly, it is not possible for a single line of code in a file. See the MSDN docs.

    On the other hand, you could probably make your single line of code a separate function, put that in a new file with partial class attributes, and put Option Strict Off on that one file. The IL compiler will probably inline your function anyway, so it will be equivalent speedwise, but will be ugly from a practical point of view.

提交回复
热议问题