Get double value to display in textbox

  • Thread starter Thread starter Newbie
  • Start date Start date
N

Newbie

Why can I not get a decimal value from my double using:

double test;
test = 1/3;
MessageBox.Show(test.ToString());
 
Because 1 and 3 are both integers

try this:

double test;
test = 1.00 / 3;
MessageBox.Show(test.ToString());
 
Or this:

double test;
test = 1/3d; // Here you are specifying that the number be a double
MessageBox.Show(test.ToString());
 
Back
Top