如何把txt里的多个空格改成一个空格 using System.Text.RegularExpressions;Text = Regex.Replace("11 22 33 44", @"( )+", "$1", RegexOptions.None); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public class MyFile{ public static void main() { StreamReader srd; string strTxtFile="D:\\mt.txt"; string s; srd = File.OpenText(strTxtFile); s = std.ReadLine(); while (s = !null) { s = Regex.Replace(s, @"( )+", "$1", RegexOptions.None); Console.Write(s); } srd.Close; // }}我是这么写的没有运行结果,菜鸟第一次写c#,请高手们指点 StreamReader srd = new StreamReader("D:\\mt.txt");string s;while ((vLine = srd.ReadLine()) != null){ s = Regex.Replace(s, @"( )+", "$1", RegexOptions.None); Console.Write(s);} while ((s = srd.ReadLine()) != null) 帮忙写个算法:两个递增数列排序后求第n个数 关于添加wcf服务引用的问题 请教 遍历Struct内的常量 ??? 关于using使用的问题 长字符串如何换行? dataGridView问题 关于C#将16进制转换成ASCii问题 今天刚完成的免费短信发送程序,敬请各位试用。 如何枚举出局域网中所有机器的名称或其它信息? Give me a hand! 问个问题 谢谢了 .. 如何同时获取并返回select语句两个字段的值?
{
public static void main()
{
StreamReader srd;
string strTxtFile="D:\\mt.txt";
string s;
srd = File.OpenText(strTxtFile);
s = std.ReadLine();
while (s = !null)
{
s = Regex.Replace(s, @"( )+", "$1", RegexOptions.None);
Console.Write(s);
}
srd.Close;
//
}
}
我是这么写的没有运行结果,菜鸟第一次写c#,请高手们指点
string s;
while ((vLine = srd.ReadLine()) != null)
{
s = Regex.Replace(s, @"( )+", "$1", RegexOptions.None);
Console.Write(s);
}