KO CSharp Directive Nullable - LIHACHTETAN/ClassicUO-Bad-Newbie-CSharp-Scripts-IDE GitHub Wiki
ะฃะบัะฐัะฝััะบะฐ ยท ะ ัััะบะธะน ยท English ยท Deutsch ยท Franรงais ยท Italiano ยท Espaรฑol ยท ็น้ซไธญๆ ยท ๆฅๆฌ่ช ยท ํ๊ตญ์ด
Null ํ์ฉ ์ปจํ ์คํธ
ํธ๋๋ถ C# ยท ์ค์ฉ ๊ฐ์ด๋
null ํ์ฉ ์ฃผ์ ๋ฐ null ํ์ฉ ๊ฒฝ๊ณ ๋ฅผ ๊ด๋ฆฌํฉ๋๋ค. ๋ฐํ์ ์ ์๋ null ๊ฒ์ฌ๋ฅผ ์ฝ์ ํ์ง ์์ต๋๋ค.
๊ฐ๋จํ ์์ (Example.cs)
์ด ์์ ๋ฅผ Example.cs๋ก ๋ฐ๋ก ์ ์ฅํ๊ณ ์ด ํ์ด์ง์ ๋ค๋ฅธ ์์ ์ ๋
๋ฆฝ์ ์ผ๋ก ์คํํ์ธ์.
Example.cs:
// PROJECT-EXAMPLE
#nullable enable
string? name = null;
System.Console.WriteLine(name ?? "Unknown");
๊ฒฐ๊ณผ:
Unknown
ํต์ฌ๋ก
#nullable enable / disable / restore / enable warnings / enable annotations
์์ 1
#nullable enable
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)
{
string? name = null;
Console.WriteLine(name ?? "Unknown");
}
}
์์ 2
#nullable enable annotations
#nullable enable warnings
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)
{
string? text = "ore";
if (text is not null) Console.WriteLine(text.Length);
}
}
๊ณต์ ์ถ์ฒ: Microsoft ํ์ต.