Re: Simple String split

Tech-Archive recommends: Fix windows errors by optimizing your registry




"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message news:MPG.2241036cbccad724ad0@xxxxxxxxxxxxxxxxxxxxxxx
Pipo <nomail@xxxxx> wrote:
String[] Channel = FileName.Split(new string[] { "\\r" },
StringSplitOptions.RemoveEmptyEntries);

The "\\r" should be "\r\n" there. Otherwise you'll only split strings
which actually contain a backslash followed by an r.

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

If you don't know how the strings are "newlined", couldn't you test for \n, \r, and \r\n? This is how I do it. Note that the order of entries in crlfs is important.

string[] crlfs = { "\r\n", "\n", "\r" };
string[] lines = myText.Split(crlfs, StringSplitOptions.None);

RobinS.
GoldMail.com

.



Relevant Pages

  • Re: Connecting to a DB / using LINQ
    ... as well, but that's a non-existing ... namespace, the compiler revieled. ... Jon Skeet - ... World class .NET training in the UK: http://iterativetraining.co.uk ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to discover the class libraries
    ... IIRC Jon Skeet was writting one, ... except where they directly interact with the language. ... I'm not sure I trust Amazon recommendations much. ... World class .NET training in the UK: http://iterativetraining.co.uk ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Identify property/object type
    ... User defined calss ... List/collection type ... Jon Skeet - ... World class .NET training in the UK: http://iterativetraining.co.uk ...
    (microsoft.public.dotnet.framework)
  • Re: break out of if
    ... Sounds like the motto for the ugliest code competition. ... oddities], move on. ... Jon Skeet - ... World class .NET training in the UK: http://iterativetraining.co.uk ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: object initializer and automatic properties
    ... Whoops - hadn't seen the anonymous type part. ... Doh! ... Jon Skeet - ... World class .NET training in the UK: http://iterativetraining.co.uk ...
    (microsoft.public.dotnet.languages.csharp)