什么是从在C#中的字符串中删除换行符的最快方法是什么? [英] What would be the fastest way to remove Newlines from a String in C#?

查看:352
本文介绍了什么是从在C#中的字符串中删除换行符的最快方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有中有一些Environment.Newline字符串。我想剥夺那些从字符串,而是带着几分像一个逗号替换换行符。

I have a string that has some Environment.Newline in it. I'd like to strip those from the string and instead, replace the Newline with something like a comma.

会是什么,在你看来,最好的办法使用为此C#.net 2.0?

What would be, in your opinion, the best way to do this using C#.NET 2.0?

推荐答案

为什么不:

string s = "foobar\ngork";
string v = s.Replace(Environment.NewLine,",");
System.Console.WriteLine(v);

这篇关于什么是从在C#中的字符串中删除换行符的最快方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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