Convert byte array To Int - CSharp System

CSharp examples for System:Byte Array

Description

Convert byte array To Int

Demo Code

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as published
 *   by the Free Software Foundation; either version 2.1 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/
using System.Text;
using System;/* w  w w  .j a v  a2  s  .c o  m*/

public class Main{
        /// <summary>
        /// 
        /// </summary>
        /// <param name="longBuffer"></param>
        /// <param name="iBufferIndex"></param>
        /// <returns></returns>
        public static long ConvertToInt64( this byte[] longBuffer, int iBufferIndex )
        {
            return BitConverter.ToInt64( longBuffer, iBufferIndex );
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="longBuffer"></param>
        /// <returns></returns>
        public static long ConvertToInt64( this byte[] longBuffer )
        {
            return BitConverter.ToInt64( longBuffer, 0 );
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="longBuffer"></param>
        /// <param name="iBufferIndex"></param>
        /// <returns></returns>
        public static long ToInt64( byte[] longBuffer, int iBufferIndex )
        {
            return BitConverter.ToInt64( longBuffer, iBufferIndex );
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="longBuffer"></param>
        /// <returns></returns>
        public static long ToInt64( byte[] longBuffer )
        {
            return BitConverter.ToInt64( longBuffer, 0 );
        }
}

Related Tutorials