System.IO.Ports.SerialPortBase.ReadLine C# (CSharp) Méthode

ReadLine() public méthode

Reads data from a serial port up to the NewLine value and decodes them as string using Encoding.
This method does not return until NewLine sequence is received.
public ReadLine ( ) : string
Résultat string
        public virtual string ReadLine()
        {
            byte[] stringData = ReadTo(Encoding.GetBytes(NewLine));

            if (stringData == null) return null;                                // ReadTo timed out
            if (stringData.Length < 1) return string.Empty;                     // two consecutive line markers

            return new string(Encoding.GetChars(stringData));                   // fails when data contains invalid bytes for the current Encoding
            // TODO: Fire an error event with raw data.
        }