如何在C#.net中逃避\ n字符 [英] How to Escape \n Character in C#.net

查看:102
本文介绍了如何在C#.net中逃避\ n字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我从命令文件中调用C#.net exe(sendmail.exe),该文件将参数传递给它,并发送一封电子邮件从exe中显示电子邮件正文中的参数内容。



参数是根据我正在运行的服务器而变化的目录(例如:\\ \\
as *)



每当我将此参数传递给exe时,它将\ n作为新行字符和

如下是打印。服务器名称为\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ >
aa1234567



有些人可以告诉我在命令文件中我可以修改什么我在哪里传递参数,以便\ n不会被视为exe中的新行字符,并且\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

使用@喜欢它..

 字符串 str =  @ 某事物 





如果有帮助,请接受并给出解决方案。

问候:

sumi


可能这可以帮助你 -

转义在C#中:字符,字符串,字符串格式,关键字,标识符



http://dotnetdud.blogspot.in/2009/01/newline-characters-in-c.html [ ^ ]


< pre lang =cs> string hello = \\ \H\\\e\\\l\\\l\\\o;
Console.Write( \t + hello + !\ n); // 你好!







尝试这样...



快乐编码:)


Hi,

I am calling a C#.net exe(sendmail.exe) from the command file which passes the parameter to it and an email will be sent to me from the exe displaying the paramet content in the body of the email.

the parameter is directory that will vary based on the server i am running (eg:\\nas*)

whenever i pass this parameter to the exe it is taking \n as new line character and
something as below is printing. the server name is \\na1234567 i am passing the same parameter to the exe.

\
aa1234567


Could some please let me know what can i modify in the command file from where i am passing the parameter so that \n wont be considered as new line character in the exe and \\na1234567 is displayed in the body of the email ?

解决方案

use @ like it..

String str= @"something \n something"



accept and rate solution if it is helpfull.
Regards:
sumi


May be this can Help You-
Escaping in C#: characters, strings, string formats, keywords, identifiers

http://dotnetdud.blogspot.in/2009/01/newline-characters-in-c.html[^]


string hello = "\u0048\u0065\u006C\u006C\u006F";
Console.Write ("\t" + hello + "!\n");            // "    Hello!"




try like this...

Happy coding:)


这篇关于如何在C#.net中逃避\ n字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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