KO CSharp Operator Null Forgiving - LIHACHTETAN/ClassicUO-Bad-Newbie-CSharp-Scripts-IDE GitHub Wiki
ะฃะบัะฐัะฝััะบะฐ ยท ะ ัััะบะธะน ยท English ยท Deutsch ยท Franรงais ยท Italiano ยท Espaรฑol ยท ็น้ซไธญๆ ยท ๆฅๆฌ่ช ยท ํ๊ตญ์ด
Null ํ์ฉ ๊ฒฝ๊ณ ์ต์
ํธ๋๋ถ C# ยท ์ค์ฉ ๊ฐ์ด๋
ํํ์์ด ๋นnull๋ก ์ฒ๋ฆฌ๋จ์ null ํ์ฉ ๋ถ์์ ์๋ฆฝ๋๋ค. ๊ฐ์ ํ์ธํ์ง ์์ผ๋ฉฐ NullReferenceException๋ก๋ถํฐ ๋ณดํธํ์ง ์์ต๋๋ค.
๊ฐ๋จํ ์์ (Example.cs)
์ด ์์ ๋ฅผ Example.cs๋ก ๋ฐ๋ก ์ ์ฅํ๊ณ ์ด ํ์ด์ง์ ๋ค๋ฅธ ์์ ์ ๋
๋ฆฝ์ ์ผ๋ก ์คํํ์ธ์.
Example.cs:
// PROJECT-EXAMPLE
string? name = "ore";
System.Console.WriteLine(name!.Length);
๊ฒฐ๊ณผ:
3
ํต์ฌ๋ก
possiblyNull!.Member
์์ 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)
{
string? text = "ore";
Console.WriteLine(text!.Length);
}
}
์์ 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)
{
Dictionary<string, string> values = new() { ["name"] = "Archer" };
values.TryGetValue("name", out string? name);
Console.WriteLine(name!.ToUpperInvariant());
}
}
๊ณต์ ์ถ์ฒ: Microsoft ํ์ต.