locked
In C# - How to create a string literal with a back slash \ as the value RRS feed

  • Question

  • Using C# in 2019.  I would like to create a string literal with a back slash \ as the value.  Need an example.

    Edcal

    Tuesday, July 9, 2019 2:34 PM

All replies

  • Check these examples:

     

       string example1 = "C:\\MyFile.txt";

       string example2 = @"C:\MyFile.txt";

     

    Each of the strings contains a ‘\’. The strings are equal.

    Tuesday, July 9, 2019 3:38 PM