KO CSharp Operator Member Access - LIHACHTETAN/ClassicUO-Bad-Newbie-CSharp-Scripts-IDE GitHub Wiki

ะฃะบั€ะฐั—ะฝััŒะบะฐ ยท ะ ัƒััะบะธะน ยท English ยท Deutsch ยท Franรงais ยท Italiano ยท Espaรฑol ยท ็น้ซ”ไธญๆ–‡ ยท ๆ—ฅๆœฌ่ชž ยท ํ•œ๊ตญ์–ด

ํšŒ์›, ํ˜ธ์ถœ ๋ฐ ์ƒ‰์ธ ์ƒ์„ฑ

ํ•ธ๋“œ๋ถ C# ยท ์‹ค์šฉ ๊ฐ€์ด๋“œ

์ ์€ ๋ฉค๋ฒ„๋ฅผ ์„ ํƒํ•˜๊ณ , ()๋Š” ์ฝœ๋Ÿฌ๋ธ”์„ ํ˜ธ์ถœํ•˜๊ณ , []๋Š” ์š”์†Œ๋‚˜ ์ธ๋ฑ์„œ๋ฅผ ์ฝ์Šต๋‹ˆ๋‹ค. ?. ๊ทธ๋ฆฌ๊ณ  ?[]๋Š” null์—์„œ ์•ก์„ธ์Šค๋ฅผ ์ข…๋ฃŒํ•ฉ๋‹ˆ๋‹ค.

๊ฐ„๋‹จํ•œ ์˜ˆ์ œ (Example.cs)

์ด ์˜ˆ์ œ๋ฅผ Example.cs๋กœ ๋”ฐ๋กœ ์ €์žฅํ•˜๊ณ  ์ด ํŽ˜์ด์ง€์˜ ๋‹ค๋ฅธ ์˜ˆ์ œ์™€ ๋…๋ฆฝ์ ์œผ๋กœ ์‹คํ–‰ํ•˜์„ธ์š”.

Example.cs:

// PROJECT-EXAMPLE
string? name = null;
System.Console.WriteLine(name?.Length ?? 0);

๊ฒฐ๊ณผ:

0

ํ†ต์‚ฌ๋ก 

value.Member / method(args) / items[index] / value?.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.ToUpperInvariant());
        Console.WriteLine(text[1]);
    }
}

์˜ˆ์‹œ 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)
    {
        string[]? names = null;
        Console.WriteLine(names?[0] ?? "Missing");
        string? text = "wood";
        Console.WriteLine(text?.Length);
    }
}

๊ณต์‹ ์ถœ์ฒ˜: Microsoft ํ•™์Šต.