Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to Convert Integer Data into Hexadecimal Data in C#
How to Convert Integer Data into Hexadecimal Data in C#
#region converts integers into 16 hexadecimal output (system functions are not allowed).

Static void test ()

{

Console. Write ("Please enter an integer such as (1000):");

Int value = int. Parse (console. ReadLine());

String s =

GetValue64 (value, reference s); //Calculate the inverse value of 16.

The string s2 =// records the correct value of 16.

Foreach (character c in s)

{

S2 = c+S2;

}

Console. WriteLine(“{ 0} converted to hexadecimal 16 {1} ",value, S2);

}

//Recursively calculate the value

Static void getValue(int value, ref string)

{

if(value/ 16 & lt; 1)

{

S += snap64 (conversion. ToString(value));

}

other

{

S += snap64 (conversion. ToString (value%16));

GetValue64(value/16, reference s);

}

}

Static string capture (string s)

{

switch

{

Case "10":

s = " A

Break;

Case "1 1":

s = " B

Break;

Case "12":

s = " C

Break;

Case "13":

s = " D

Break;

Case "14":

s = " E

Break;

Case "15":

s = " F

Break;

Default value:

Break;

}

Return to s;

}

# End area