Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Best method to strip the CRLF in C#
Message
De
30/04/2007 11:29:03
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
À
30/04/2007 11:23:15
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Divers
Thread ID:
01221137
Message ID:
01221143
Vues:
18
>>I am working with a serial port object and receive a line feed and carriage return as the ending on each incoming data stream. I would like to strip these off each time before passing the string on. What is the most appropriate method to do this? string.substring(), string.trim(), or something else?
>
>There are many ways to skin a cat.
>Here's one:
>
>string txt;
>txt = txt.Replace("\r\n", string.Empty);
>
Ok so if might look like this:
string read = "EVT:TRIGGER Read GPIO 0" + "\r\n"

I want to then strip the line feed and return back off and leave the rest. You are saying this will replace with an empty string on the end of it? That works for me. Thanks, that is pretty clean method to use.
Tim
Timothy Bryan
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform