没有在字符串C#中获得换行符 [英] not getting line break in a string C#

查看:236
本文介绍了没有在字符串C#中获得换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI伙计们,



我正在尝试在字符串中插入换行符,但没有得到...



我的代码:



HI guys,

I'm trying to insert newline in a string, but didn't get...

my code:

string body =   "From :" + from + "\r"+
                            "To :" + to + "\r"+
                            "Sub :" + sub + "\r"+
                            ebody.Text;





即使我试过\ n,\ r和\ n \\\



Plz建议我,



谢谢



even i tried \n , \r, and \n\r

Plz suggest me,

Thanks

推荐答案

你在asp脚本中使用这个字符串所以你需要使用html换行标记,这是< br>

代替 \ r 使用 br tag
You are using here this string in asp script so you need to use html line break tag which is <br>
so instead of \r use br tag


string breakTag = "<br>";
           string body = "From :" + from + breakTag +
                           "To :" + to + breakTag +
                           "Sub :" + sub + breakTag +
                           ebody.Text;


string strMailBody =string.empty;
strMailBody = "<table width="\"100%\"" cellpadding="\"0\"" class="\"viewtbl\"" cellspacing="\"0\"" border="\"0\""><tr><td>";
strMailBody += "<tr><td height="\"10px\""></td></tr>";
strMailBody += "<tr><td></td></tr>";
strMailBody += "<tr><td style="\"border-bottom:" 2px="" solid="" mode="hold" />strMailBody += "</tr></td></tr></table>";









用这种方式做表..........





do in this way using table..........


这篇关于没有在字符串C#中获得换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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