how to escape key words in c#?

后端 未结 3 1538
名媛妹妹
名媛妹妹 2020-12-17 21:25

I want to do the equivalent of the following VB in c#

Function([class]) \"hello\"

This would be the same as this in c#

<         


        
相关标签:
3条回答
  • 2020-12-17 22:04

    You can prefix any keyword with a @.

    But I don't think it's a recommended practice, and code analysis complains about it for sure.

    0 讨论(0)
  • 2020-12-17 22:06

    You need to add @ to variable names:

    @class

    But it is a very bad practice. Every time you name your variable as a keyword a kitten dies :)

    0 讨论(0)
  • 2020-12-17 22:14

    Use @ for reserved words:

    @class=>"hello"
    
    0 讨论(0)
提交回复
热议问题