Decodes the Encoded int32 data. - CSharp System

CSharp examples for System:Int32

Description

Decodes the Encoded int32 data.

Demo Code


using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;// ww  w  .jav  a  2 s. com

public class Main{
        /// <summary>
        /// Decodes the Encoded int32 data.
        /// </summary>
        /// <param name="v">Encoded Data.</param>
        /// <returns>Decoded Data.</returns>
        public static int DecodeInt32(byte[] v)
        {
            if ((((v[0] | v[1]) | v[2]) | v[3]) < 0)
            {
                return -1;
            }
            return ((((v[0] << 0x18) + (v[1] << 0x10)) + (v[2] << 8)) + v[3]);
        }
        #endregion

        /* Decoding Functions */
        #region Decoding/DeCipher Methods
        /// <summary>
        /// Decodes the Encoded int32 data.
        /// </summary>
        /// <param name="v">Encoded Data.</param>
        /// <returns>Decoded Data.</returns>
        public static int DecodeInt32(string v)
        {
            if ((((v[0] | v[1]) | v[2]) | v[3]) < 0)
            {
                return -1;
            }
            return ((((v[0] << 0x18) + (v[1] << 0x10)) + (v[2] << 8)) + v[3]);
        }
}

Related Tutorials