Using / or \\ for folder paths in C#

后端 未结 5 2037
野的像风
野的像风 2020-12-10 11:13

When writing file paths in C#, I found that I can either write something like \"C:\\\" or \"C:/\" and get the same path. Which one is recommended? I heard somewhere that usi

5条回答
  •  盖世英雄少女心
    2020-12-10 11:41

    This isn't a C# issue - it's a Windows issue. Paths in Windows are normally shown with a backslash: C:. In my opinion, that's what you should use in C#. Use @"C:\" to prevent special handling of backslaash characters.

提交回复
热议问题