字符串操作 [英] String manipulations

查看:83
本文介绍了字符串操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



Hi,

string c = dr["tasks"].ToString();
string h = c.Substring(0, 36);
string<pre> k = s.Substring(36, g);
string p= h + System.Environment.NewLine + k;


第一步,我有一个字符串c,并使用"substring"关键字将其分为两个字符串.在另一步骤中,我插入了新行.

现在,我想在程序中的某些位置删除字符串p中的 System.Environment.NewLine (即(我不能在任何位置使用上述字符串,例如c,h,k).现在我只有字符串p;所以我想从该字符串中删除换行符.

我该怎么做?
请给我一个主意.


In the first step, I have a string c and I have divided it into two strings using "substring" keyword. In other step, I have inserted the new line.

Now, I want to remove the System.Environment.NewLine in the string p some where in the program, i.e (i cannot use the above strings like c,h,k any where). Right now I have only string p ; so I want to remove the newline from that string.

How can I do it?
Please give me an idea.

推荐答案

使用Replace方法:

Use the Replace method :

p.Replace(System.Environment.NewLine,"")



干杯



Cheers


这篇关于字符串操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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