四捨五入を行うサンプル

  1. using System;
  2. using System.Text;
  3. namespace ConsoleApplication1
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Console.WriteLine("Math.Round(1.2) = " + Math.Round(1.2));
  10.             Console.WriteLine("Math.Round(1.5) = " + Math.Round(1.5));
  11.             Console.WriteLine("Math.Round(-1.2) = " + Math.Round(-1.2));
  12.             Console.WriteLine("Math.Round(-1.5) = " + Math.Round(-1.5));
  13.             Console.ReadLine();
  14.         }
  15.     }
  16. }

image

戻る