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());
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top