Force parentheses even when calling parameterless functions in VB.NET?

后端 未结 1 749
感动是毒
感动是毒 2020-12-20 11:42

in VB.NET it is possible to omit parentheses when you call a parameterless function. However this can be very confusing because developers could think that a statement is ac

相关标签:
1条回答
  • 2020-12-20 12:11

    No there is no such option in the VB.Net compiler. Parens are optional and there is no warning or error that exist for using a lack of them.

    The other reason is that VB.Net is a language which tries to be flexible and get the syntax out of the way of the user. This type of restriction goes against this general philosophy.

    Another issue to consider is that it's not a universally enforceable restriction. VB.Net allows for late binding scenarios whenever option strict is set to off. In these scenarios it is impossible for the VB.Net compiler to determine ahead of time if a particular call is a property, statement or not a valid call at all.

    0 讨论(0)
提交回复
热议问题