OpenRA.StreamExts.ReadString C# (CSharp) Method

ReadString() public static method

public static ReadString ( this s, Encoding encoding, int maxLength ) : string
s this
encoding System.Text.Encoding
maxLength int
return string
        public static string ReadString(this Stream s, Encoding encoding, int maxLength)
        {
            var length = s.ReadInt32();
            if (length > maxLength)
                throw new InvalidOperationException("The length of the string ({0}) is longer than the maximum allowed ({1}).".F(length, maxLength));

            return encoding.GetString(s.ReadBytes(length));
        }