KO CSharp Operator Null Coalescing - LIHACHTETAN/ClassicUO-Bad-Newbie-CSharp-Scripts-IDE GitHub Wiki
ะฃะบัะฐัะฝััะบะฐ ยท ะ ัััะบะธะน ยท English ยท Deutsch ยท Franรงais ยท Italiano ยท Espaรฑol ยท ็น้ซไธญๆ ยท ๆฅๆฌ่ช ยท ํ๊ตญ์ด
ํธ๋๋ถ C# ยท ์ค์ฉ ๊ฐ์ด๋
?? null์์๋ง ์๋น ๊ฐ์ ์ ํํฉ๋๋ค. ??= ์ผ์ชฝ ๋ถ๋ถ์ด ์์ง null์ธ ๊ฒฝ์ฐ์๋ง ์๋๋ค.
์ด ์์ ๋ฅผ Example.cs๋ก ๋ฐ๋ก ์ ์ฅํ๊ณ ์ด ํ์ด์ง์ ๋ค๋ฅธ ์์ ์ ๋
๋ฆฝ์ ์ผ๋ก ์คํํ์ธ์.
Example.cs:
// PROJECT-EXAMPLE
string? name = null;
name ??= "Player";
System.Console.WriteLine(name);๊ฒฐ๊ณผ:
Player
value ?? fallback / value ??= fallbackusing 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");
name ??= "Archer";
Console.WriteLine(name);
}
}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)
{
List<int>? values = null;
(values ??= []).Add(3);
Console.WriteLine(values.Count);
}
}๊ณต์ ์ถ์ฒ: Microsoft ํ์ต.