Click here to Skip to main content
15,890,947 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
string vbn = chrs1 + "." + chm1;
                    double sh = Convert.ToDouble(vbn);
                    string chm1str = chm1.ToString();
                    string chmstr = chm.ToString();
                    chmstr = chmstr.Substring(Math.Max(0, chmstr.Length - 1));
                    chm1str = chm1str.Substring(Math.Max(0, chm1str.Length - 1));

                    string s = chrs1 + "." + chm1;
                    totaltimeptod = Decimal.Round(Convert.ToDecimal(s), 2, MidpointRounding.AwayFromZero);

                    totaltime = Convert.ToDecimal(chrs + "." + chm);
Posted
Comments
CPallini 19-Jan-16 4:24am    
What is the offending line? What are the input values? Details, details, we need details, after all.
[no name] 19-Jan-16 4:35am    
What is the input value of variables chrs1, chm1, chm, chrs
amagitech 19-Jan-16 4:42am    
it's not clear.

1 solution

You write chm.ToString(), so I assume chm is not a string, but a decimal or other things.
You cannot concatenate strings and decimals in the same operation, there is a nonsense for the interpreter.
if you write chrs1 + "." . chm1, you MUST have chrs1 and chm1 defined as a string, because there is no implicit conversion between decimal and string.
You must write something like chrs1.ToString() + "." + chm1.ToString();
But be aware of some problems you can have, if chrs1 and chms1 are not integer...what will you do with the multiple dots in your string ?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900