ZH TW CSharp Keyword ulong - LIHACHTETAN/ClassicUO-Bad-Newbie-CSharp-Scripts-IDE GitHub Wiki
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
C#: ulong
無符號 64 位元整數。
簡單範例 (Example.cs)
請將此範例另存為 Example.cs,並與本頁其他範例分開執行。
Example.cs:
// PROJECT-EXAMPLE
ulong amount = 12UL;
System.Console.WriteLine(amount + 2);
結果:
14
句法
ulong value = 120UL;
變數的類型決定了運算的範圍和規則。要檢查整數溢出,請使用checked;用於文字轉換 - TryParse。
例1:基本形式
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)
{
ulong first = 120UL;
ulong second = 2;
Console.WriteLine(first + second);
}
}
例2:另一種實用形式
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)
{
ulong[] values = [120UL, 2, 3];
foreach (ulong value in values) Console.WriteLine(value);
Console.WriteLine(ulong.MaxValue);
}
}
官方來源:Microsoft學習。