Convert byte array To UInt - CSharp System

CSharp examples for System:Byte Array

Description

Convert byte array To UInt

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;//from   w w  w .jav a  2  s.c o m

public class Main{
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ushortBuffer"></param>
        /// <param name="iBufferIndex"></param>
        /// <returns></returns>
        public static ushort ToUInt16( byte[] ushortBuffer, int iBufferIndex )
        {
            return BitConverter.ToUInt16( ushortBuffer, iBufferIndex );
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ushortBuffer"></param>
        /// <returns></returns>
        public static ushort ToUInt16( byte[] ushortBuffer )
        {
            return BitConverter.ToUInt16( ushortBuffer, 0 );
        }
}

Related Tutorials