How would I convert a string that represents an integer like "4322566" to a hex string?
5 Answers
int temp = 0;
string hexOut = string.Empty;
if(int.TryParse(yourIntString, out temp))
{
hexOut = temp.ToString("X");
}
To handle larger numbers per your comment, written as a method
public static string ConvertToHexString(string intText)
{
long temp = 0;
string hexOut = string.Empty;
if(long.TryParse(intText, out temp))
{
hexOut = temp.ToString("X");
}
return hexOut;
}
Try
int otherVar= int.Parse(hexstring ,
System.Globalization.NumberStyles.HexNumber);
1 Comment
Femaref
int -> string, not string -> int.