KO CSharp Keyword as - LIHACHTETAN/ClassicUO-Bad-Newbie-CSharp-Scripts-IDE GitHub Wiki
ะฃะบัะฐัะฝััะบะฐ ยท ะ ัััะบะธะน ยท English ยท Deutsch ยท Franรงais ยท Italiano ยท Espaรฑol ยท ็น้ซไธญๆ ยท ๆฅๆฌ่ช ยท ํ๊ตญ์ด
C#: as
ํธ๋๋ถ C# ยท ์ค์ฉ ๊ฐ์ด๋
์ฐธ์กฐ ๋๋ null ํ์ฉ ๊ฐ์ ๋ณํํ๋ ค๊ณ ์๋ํฉ๋๋ค. ๋ณํ์ด ๋ง์ง ์์ผ๋ฉด null๋ฅผ ๋ฐํํฉ๋๋ค.
๊ฐ๋จํ ์์ (Example.cs)
์ด ์์ ๋ฅผ Example.cs๋ก ๋ฐ๋ก ์ ์ฅํ๊ณ ์ด ํ์ด์ง์ ๋ค๋ฅธ ์์ ์ ๋
๋ฆฝ์ ์ผ๋ก ์คํํ์ธ์.
Example.cs:
// PROJECT-EXAMPLE
object value = "ore";
string? text = value as string;
System.Console.WriteLine(text ?? "Missing");
๊ฒฐ๊ณผ:
ore
ํต์ฌ๋ก
value as Type
์์ 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)
{
object value = "ore";
string? text = value as string;
Console.WriteLine(text ?? "Missing");
}
}
์ 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)
{
object value = 12;
int? number = value as int?;
Console.WriteLine(number.GetValueOrDefault());
}
}
๊ณต์ ์ถ์ฒ: Microsoft ํ์ต.