hoe kan ik van hexadecimaal naar binair rekenen?
andersom doe ik:
private void BTNHex_Click(object sender, EventArgs e)
{
try
{
int hex;
hex = Convert.ToInt32(TBXInvoerA.Text);
TBXUitvoer.Text = string.Format(" {0:X} ", hex);
}
catch
{
TBXUitvoer.Text = "Ongeldige invoer";
}
}
dit is voor een rekenmachine die ik aan het maken ben.
tbxinvoerA is de string waar het getal komt.
ik heb dit geprobeerd
private void BTNDecimaal_Click(object sender, EventArgs e)
{
try
{
int decimaal;
decimaal = Convert.ToInt64(TBXInvoerA.Text);
TBXUitvoer.Text = string.Format("x", decimaal);
}
catch
{
TBXUitvoer.Text = "Ongeldige invoer";
}
}
maar ik krijg fout: Error 1 Cannot implicitly convert type 'long' to 'int'. An explicit conversion exists (are you missing a cast?) C:\Users\sven vanden boogaart\Documents\Visual Studio 2008\Projects\rekenmachinesven\rekenmachinesven\Form1.cs 627 28 rekenmachinesven
met vriendelijke groet
===============================================================================================================
http://stackoverflow.com/questions/74148/how-to-convert-numbers-between-hex-and-decimal-in-c
maar ik snap het niet
andersom doe ik:
private void BTNHex_Click(object sender, EventArgs e)
{
try
{
int hex;
hex = Convert.ToInt32(TBXInvoerA.Text);
TBXUitvoer.Text = string.Format(" {0:X} ", hex);
}
catch
{
TBXUitvoer.Text = "Ongeldige invoer";
}
}
dit is voor een rekenmachine die ik aan het maken ben.
tbxinvoerA is de string waar het getal komt.
ik heb dit geprobeerd
private void BTNDecimaal_Click(object sender, EventArgs e)
{
try
{
int decimaal;
decimaal = Convert.ToInt64(TBXInvoerA.Text);
TBXUitvoer.Text = string.Format("x", decimaal);
}
catch
{
TBXUitvoer.Text = "Ongeldige invoer";
}
}
maar ik krijg fout: Error 1 Cannot implicitly convert type 'long' to 'int'. An explicit conversion exists (are you missing a cast?) C:\Users\sven vanden boogaart\Documents\Visual Studio 2008\Projects\rekenmachinesven\rekenmachinesven\Form1.cs 627 28 rekenmachinesven
met vriendelijke groet
===============================================================================================================
http://stackoverflow.com/questions/74148/how-to-convert-numbers-between-hex-and-decimal-in-c
maar ik snap het niet
Laatst bewerkt: