CSharp examples for System:Byte
Reads a 1 byte length prefixed ansi string from the given BinaryReader
/*// w w w. j a v a 2s . co m Copyright 2013 - 2016 Kees van Spelde Licensed under The Code Project Open License (CPOL) 1.02; you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.codeproject.com/info/cpol10.aspx Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ using System.Text; using System.IO; public class Main{ #endregion #region Read1ByteLengthPrefixedAnsiString /// <summary> /// Reads a 1 byte length prefixed ansi string from the given <paramref name="binaryReader" /> /// </summary> /// <param name="binaryReader"></param> /// <returns></returns> internal static string Read1ByteLengthPrefixedAnsiString(BinaryReader binaryReader) { var length = (int) binaryReader.ReadByte(); var bytes = binaryReader.ReadBytes(length); var str = Encoding.UTF8.GetString(bytes); return str.TrimEnd('\0'); } }