No one thinks you are stupid, but you need to tell us exactly what is not working. What is wrong exactly? The only problem I see is this line:
Code:
int RadiusToCircumference = number1 * 2 * pi;
So that will truncate the result to an integer. Perhaps you wanted it that way, but I don't know because you didn't explain what the actual problem is.
If you liked my post go ahead and give me an upvote so that my epee.... ahem, reputation will grow.
These code should work based on these assumptions:
- For your own code I have assumed you are using C# 4.0 so I've done same.
- Here's what I think, if these varaible numericUpDown1.Value is of type double then that line of code should not be a problem else you'd need to explicitly cast(i.e. force a conversion from whatever type it is to type decimal) to do so just add (decimal) in front of that variable. Because I
have little idea about your numericUpDown1.Value, I initialized number1 variable from a textbox input.
As for the statement:
int RadiusToCircumference = number1 * 2 * pi;
observed that I've forced a conversion using a cast operator i.e. (double).
***********I hope these makes a good contribution to your understanding of C#***********
***********You can download my own version of your code code. See attachment.**********
It's best (numerically) to delay casting as late as possible:
[double]
double circum = (double)(radius * 2) * Math.Pi;
[/double]
In this case, it makes no difference, but it might if you were doing something more complicated.
Actually, an explicit cast is not required here. int * double will be automatically promoted to double.
Best Regards,
BioPhysEngr http://blog.biophysengr.net
--
All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.
These code should work based on these assumptions:
- For your own code I have assumed you are using C# 4.0 so I've done same.
- Here's what I think, if these varaible numericUpDown1.Value is of type double then that line of code should not be a problem else you'd need to explicitly cast(i.e. force a conversion from whatever type it is to type decimal) to do so just add (decimal) in front of that variable. Because I
have little idea about your numericUpDown1.Value, I initialized number1 variable from a textbox input.
As for the statement:
int RadiusToCircumference = number1 * 2 * pi;
observed that I've forced a conversion using a cast operator i.e. (double).
***********I hope these makes a good contribution to your understanding of C#***********
***********You can download my own version of your code code. See attachment.**********
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.