Hex To Int - CSharp System

CSharp examples for System:Hex

Description

Hex To Int

Demo Code

//     Copyright (c) Microsoft Corporation.  All rights reserved.
using System.Text;
using System;/* ww w  .j a v  a 2 s .  c  om*/

public class Main{
        public static int HexToInt( char h ) {
			return ( h >= '0' && h <= '9' ) ? h - '0' :
			( h >= 'a' && h <= 'f' ) ? h - 'a' + 10 :
			( h >= 'A' && h <= 'F' ) ? h - 'A' + 10 :
			-1;
		}
}

Related Tutorials