Repository navigation
ZH TW CSharp Keyword double
Codex edited this page Oct 11, 2026
·
2 revisions
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
64位浮點二進制數;近似算術。
請將此範例另存為 Example.cs,並與本頁其他範例分開執行。
Example.cs:
// PROJECT-EXAMPLE
double amount = 12.5D;
var result = amount + 2;
System.Console.WriteLine(result.ToString(System.Globalization.CultureInfo.InvariantCulture));結果:
14.5
double value = 12.5D;變數的類型決定了運算的範圍和規則。要檢查整數溢出,請使用checked;用於文字轉換 - TryParse。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
public static class Program
{
public static async Task Main(string[] args)
{
double first = 12.5D;
double second = 2;
Console.WriteLine(first + second);
}
}using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
public static class Program
{
public static async Task Main(string[] args)
{
double[] values = [12.5D, 2, 3];
foreach (double value in values) Console.WriteLine(value);
Console.WriteLine(double.MaxValue);
}
}官方來源:Microsoft學習。
ClassicUO — Bad Newbie & C# Scripts IDE