I am writing a logging system for our site and it looks at changes to Entities to see if they should be logged. I keep having a problem where the version of the Entity in the database shows decimal numbers (in string format) as "132.0000" and the current Entity has it as "132" with no decimal places. Is there a way that I can force it to either remove the ".0000" from one or add it to the other?
6 Answers
If you always want to remove the decimal, why not cast the object to an int and then make a string of it?
1 Comment
Sebastian Mach
what you mean is "fraction",
decimal is a C# datatypeYou can use formatter string : F4 xxx.ToString("F4")
1 Comment
Sebastian Mach
No, generally, the
School of Converting Everything to String for Comparison is wrong, e.g. with floating point, you'll loose information in string conversion, if done non-carefully.