| Convert number to Hex-string C# |
| Section: .NET General | Rating: Not rated yet! |
 | CodeGod submitted this resource The member's homepage is http://www.codegod.de Visit the profile here |
A snippet to convert an Int32-value to a Hex-string. To use it, you have to add a reference to the assembly Mircosoft.VisualBasic which contains some nice shortcuts for such functionalities.
/// <summary>
/// Converts an Int32 value to hex-string
/// </summary>
/// <param name="value">input</param>
/// <returns>Hex-string</returns>
/// <example>
/// string s = IntToHex(19988);
/// s is 4E14
/// </example>
private static string IntToHex(Int32 value)
{
return Microsoft.VisualBasic.Conversion.Hex(value);
}