c# - input string is not in a correct format -


I want to calculate percentages. But the compiler is giving an error that the input string is not in the correct format. Is there something elusive that I am missing here?

  Private Double Copy () {Double A = Convert. ToDouble (tbEnglish.Text + tBUrdu.Text + tbPhysics.Text + tbChemistry.Text + tbMaths.Text); Double D = 500; Double LLL Result = (A / D) * 100; Return LBL Result; }  

You are adding strings and then attempting to change that one result Are double. You can try to parse "75.692.156.378.272.3" for the results of 75.6, 92.1, 56.3, 78.2 and 72.3.

Parsing each value and then yoga them.

However, I strongly recommend that you use double instead of decimal instead of you Trysepse Instead of using pars should be considered so that you can handle user input errors in a beautiful way. Here parse :

  the public decimal mean percentage () {decimal sum = decimal Purse (TBENGTETIC) + is sticking solution with decimal. Mercury (TBURW Text) + Decimal Purse (tbfishx text) + decimal Purse (tbcmustry text) + decimal Purse (TB maths. Text); Refund amount / 5m; }  

By interest, why are you divided into 500 and then 100 times your original code? Why not just divide by 5 (as I have now, I have seen what was happening)?

As a side note, it is very important to distinguish between compile-time errors and execution time errors This compiler is saying that The input string was not in the correct format - it was converted to . Repeat method, at execution time. In this case it was relatively clear, but in other circumstances we were trying to find the problem of compilation time while chasing our tail for a while, when in fact it failed in execution time.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -