formatting strings with backslash

前端 未结 4 674
闹比i
闹比i 2021-01-22 22:15

I\'m a newbie to c# so hopefully this one isn\'t too hard for a few of you.

I\'m trying to build a string that has a \\ in it and I am having difficulty getting just one

4条回答
  •  说谎
    说谎 (楼主)
    2021-01-22 22:47

    I'm guessing you're getting confused by the debugger.

    If you hover your mouse over a local variable in VS, strings will be escaped so a single \ will display as \\.

    To see what your string really is, output it somewhere for display (e.g., to the console) or hover your mouse on the variable, click on the arrow next to the little magnifying glass that appears, and select "Text Visualizer."

提交回复
热议问题