Clearest way to declare a char value containing a single quote/apostrophe

前端 未结 6 1322
庸人自扰
庸人自扰 2021-01-07 16:22

To declare a char value in C# we just surround the character with single quotes: \'x\'.

But what is the \"clearest\" way to declare a char value that

6条回答
  •  天涯浪人
    2021-01-07 17:16

    For a char I would use

    myChar = '\'';
    

    The backslash is the standard escape key in both strings and characters, and most people should be able to understand this just fine.

提交回复
热议问题