KO CSharp Keyword static - LIHACHTETAN/ClassicUO-Bad-Newbie-CSharp-Scripts-IDE GitHub Wiki

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

C#: static

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

์ธ์Šคํ„ด์Šค ๋Œ€์‹  ํ˜•์‹์— ๋ฉค๋ฒ„๋ฅผ ๋ฐ”์ธ๋”ฉํ•ฉ๋‹ˆ๋‹ค. ์ •์  ํด๋ž˜์Šค์—๋Š” ์ •์  ๋ฉค๋ฒ„๋งŒ ํฌํ•จ๋ฉ๋‹ˆ๋‹ค. ์ •์  ๋žŒ๋‹ค๋Š” ์ง€์—ญ ๋ณ€์ˆ˜๋ฅผ ์บก์ฒ˜ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

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

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

Example.cs:

// PROJECT-EXAMPLE
System.Console.WriteLine(Tools.Double(4));
static class Tools { public static int Double(int x) => x * 2; }

๊ฒฐ๊ณผ:

8

ํ†ต์‚ฌ๋ก 

static class Tools { public static int Value { get; } }

์˜ˆ์‹œ 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)
    {
        Console.WriteLine(Tools.Double(6));
    }
}
public static class Tools { public static int Double(int value) => value * 2; }

์˜ˆ 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)
    {
        int[] values = [1, 2, 3];
        Console.WriteLine(values.Select(static value => value * value).Sum());
    }
}

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