Other ways of writing \ in C#

I have a bit of code that writes to a text document and i want to do this:

pathtxt.Text = pathtxt.Text + treeView1.SelectedNode.Text + "\"; 

but it thinks the \ is the start of a comment or something so how do i make it do a \ . Thank you

Jon Skeet
people
quotationmark

\ is used for escape sequences in text literals for C#. The compiler doesn't think it's the start of a comment: it thinks it's the start of an escape sequence. So you either need to use "\\" (i.e. the escape sequence for backslash) or @"\" (a verbatim string literal, which doesn't allow escape sequences).

Path.Combine is a generally preferred way of creating paths from multiple segments, however.

people

See more on this question at Stackoverflow