你如何编写反斜杠的代码 [英] How do you write the code for a Backslash

查看:318
本文介绍了你如何编写反斜杠的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你如何编写反斜杠的代码?



我想要像回车一样的代码:



a = b + vbcrlf + c;



除了BackSlash。



我遇到了麻烦使用此代码:

  var  localpathandfile = TextBox2.Text +   \+ System.IO.Path.GetFileName(FileUpload1.FileName).ToString();  



我收到错误\



当我离开\ out时没有错误。

解决方案

只需使用两个反斜杠:\\

第一个用作转义字符允许字符串常量中的控制字符。


由于反斜杠被视为转义字符,因此必须使用两个反斜杠才能得到一个反斜杠(\\)。

<块引用>试试2反斜杠(\\)



它将反斜杠编码为反斜杠。单个反斜杠启动代码,例如\ n for newline


How do you write the code for a Backslash?

I want the code like carriage return:

a = b + vbcrlf + c;

except with BackSlash.

I am having trouble with this code:

var localpathandfile = TextBox2.Text + "\" + System.IO.Path.GetFileName(FileUpload1.FileName).ToString();


I get the error at \

When I leave \ out there is no error.

解决方案

Just use two backslashes thus: "\\"
The first one is used as the escape character to allow control characters in string constants.


Since backslash is treated as an escape character you must use two backslashes to get a single one ("\\").


try 2 Backslash ( "\\" )

it's coding the Backslash to be a backslash. a single backslash starts a code like \n for newline


这篇关于你如何编写反斜杠的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆