Mega Code Archive

 
Categories / C# / Data Types
 

Get Compressed Int Size

using System; using System.Collections.Generic; using System.Text; using System.Reflection; public static class Utility {     public static uint GetCompressedIntSize(byte firstByte)     {         if ((firstByte & 0x80) == 0)             return 1;         else if ((firstByte & 0xC0) == 0x80)             return 2;         else if ((firstByte & 0xE0) == 0xC0)             return 4;         else             throw new NotSupportedException();     } }