when to use @ in c#?

前端 未结 5 1148
春和景丽
春和景丽 2020-12-06 04:44

I use @ symbol with local path only, but when do I use @ exactly?

5条回答
  •  春和景丽
    2020-12-06 05:38

    You use @ before strings to avoid having to escape special characters.

    This from the MSDN:

    The advantage of @-quoting is that escape sequences are not processed, which makes it easy to write, for example, a fully qualified file name:

    @"c:\Docs\Source\a.txt" // rather than "c:\\Docs\\Source\\a.txt"

提交回复
热议问题