Add another button to your form, and set the following properties
for it in the Properties Window:
Name: btnDouble
Location: 110, 130
Text: Double
Double click your new button to get at the code. Add the following three lines
to your button code:Location: 110, 130
Text: Double
double myDouble;
myDouble = 0.007;
MessageBox.Show(myDouble.ToString());
Your coding window should now look like this:Halt your programme and return to the coding window. Change this line:
myDouble = 0.007;
to this:
myDouble = 12345678.1234567;
Run your programme and click your double button. The message box correctly
displays the number. Add another number on the end, though, and C# will again
round up or down. The moral is, if you want accuracy, careful of rounding!In the next part, you'll see how to add up in C#.
0 comments:
Post a Comment