Пример #1
0
        public static string ConvertECUParamToString(object resultValue)
        {
            string result;

            if (resultValue is char)
            {
                result = ((int)((char)resultValue)).ToString(CultureInfo.InvariantCulture);
            }
            else if (resultValue is double)
            {
                result = ((double)resultValue).ToString(CultureInfo.InvariantCulture);
            }
            else if (resultValue is float)
            {
                result = ((float)resultValue).ToString(CultureInfo.InvariantCulture);
            }
            else if (resultValue is byte[])
            {
                byte[] array = (byte[])resultValue;
                result = FormatConverter.ByteArray2String(array, (uint)array.Length);
            }
            else
            {
                result = resultValue.ToString();
            }
            return(result);
        }
Пример #2
0
        public static string Convert6BitNibblesTo4DigitString(byte[] inBuf, uint offset)
        {
            char c  = FormatConverter.DecodeFAChar((char)(inBuf[(int)offset] >> 2));
            char c2 = FormatConverter.DecodeFAChar((char)((int)(inBuf[(int)offset] & 3) << 4 | inBuf[(int)(offset + 1U)] >> 4));
            char c3 = FormatConverter.DecodeFAChar((char)((int)(inBuf[(int)(offset + 1U)] & 15) << 2 | (inBuf[(int)(offset + 2U)] & 192) >> 6));
            char c4 = FormatConverter.DecodeFAChar((char)(inBuf[(int)(offset + 2U)] & 63));

            return(c.ToString(CultureInfo.InvariantCulture) + c2.ToString(CultureInfo.InvariantCulture) + c3.ToString(CultureInfo.InvariantCulture) + c4.ToString(CultureInfo.InvariantCulture));
        }