none
to use single backslash character in a string

    Question

  • hi,

    i am making a string in which i am using '\' in between. but at run time it becomes '\\' in that string which my application does not accept.

    how can i use a single backslash character in a string?

    regards,

    divya

     

    Thursday, March 29, 2007 6:42 AM

Answers

  • Are you seeing the double slash in the debugger?

    The debugger will show a double backslash for strings that contain a single backslash.  The theory is that you can then copy that string to the clipboard and paste it into C# code without having to put a @ in the front or convert all the single slashes to double slashes.
    Thursday, March 29, 2007 7:23 AM
  • use the following code to understand this concept

    string test = "abc\\xyz";

    MessageBox.Show(test);

    Thursday, March 29, 2007 6:54 AM

All replies

  • use the following code to understand this concept

    string test = "abc\\xyz";

    MessageBox.Show(test);

    Thursday, March 29, 2007 6:54 AM
  • use the @ character before the string

    e.g     MessageBox.Show(@"This is \ ");
    Thursday, March 29, 2007 6:57 AM
  • Are you seeing the double slash in the debugger?

    The debugger will show a double backslash for strings that contain a single backslash.  The theory is that you can then copy that string to the clipboard and paste it into C# code without having to put a @ in the front or convert all the single slashes to double slashes.
    Thursday, March 29, 2007 7:23 AM