Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > C#/VB.NET Convert double to hexadecimal and vice versa
 

C#/VB.NET Convert double to hexadecimal and vice versa

Hi!

How to convertdouble to hexadecimal and vice versa in C#/VB.NET?

Thanks

PS:

The following works code snippet in C# works for "int to hexadecimal and vice versa" but not for (corresponding) "double to hexadecimal and vice versa":

Code snippet:

using System;
using System.Collections.Generic; // Note

class MyClass
{
public string IntToHex(int number)
{
return String.Format("{0:X}", number);
}

public int HexToInt(string hexString)
{
return int.Parse(hexString, System.Globalization.NumberStyles.HexNumber, null);
}
}

class MainClass
{
static void Main()
{
int i = 100;
string str = Convert.ToString(i, 16); //base = 2, 8,10 or 16
Console.WriteLine(str);
Console.WriteLine(0x64);
MyClass mc = new MyClass();
Console.WriteLine("Integer to Hexadecimal: {0} \n", mc.IntToHex(100));
Console.WriteLine("Hexadecimal to Integer: {0} \n", mc.HexToInt("64"));
}
}

recherche  Thursday, June 05, 2008 10:00 AM
Lucian Baciu  Thursday, June 05, 2008 10:30 PM
Lucian Baciu  Thursday, June 05, 2008 10:30 PM

You can use google to search for other answers

Custom Search

More Threads

• Calling Web Service through Proxy Server
• Problem with SQLDependency "Cross-thread operation not valid"
• DataTable.Merge() not updating bound control
• GridView
• How to display the subitems of the data in a combobox from another table
• Crystal Report Help
• How to determine if a field in a row have change?
• cross thraed problem
• Binding ComboBox to business object issue
• button column in datagirdview