In C#, the numbers are given into two decimals
How to use the function to give up the numbers in C#into two numbers?
Math.Round
Answer:
function to give up the numbers into two decimals, please follow the following steps:
Math.Round
Declarize your number:
Math.Round
Save the post -entered value in another decimal variable, or directly use it.
Math.Round
You can use the following re -loading designated bankers to give up the law (50 % of the four houses and six entrances):
<code class="language-csharp">decimal a = 1.994444M; Console.WriteLine(Math.Round(a, 2)); // 输出:1.99 decimal b = 1.995555M; Console.WriteLine(Math.Round(b, 2)); // 输出:2.00</code>
The banker's entry method has entered the middle value to the closest integer integer. You can find more information about this theme here.
The above is the detailed content of How to Round Numbers to Two Decimal Places in C# Using Math.Round()?. For more information, please follow other related articles on the PHP Chinese website!