CSharp Keyword ulong - LIHACHTETAN/ClassicUO-Bad-Newbie-CSharp-Scripts-IDE GitHub Wiki
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
C#: ulong
Довідник C# · Практичне керівництво
Беззнакове 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 Learn.