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

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

๋žŒ๋‹ค์‹๊ณผ ๋ณธ๋ฌธ์‹

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

์ต๋ช… ํ•จ์ˆ˜ ๋˜๋Š” ๊ฐ„๊ฒฐํ•œ ํ‘œํ˜„์‹ ๋ณธ๋ฌธ ๋ฉค๋ฒ„๋ฅผ ์„ ์–ธํ•ฉ๋‹ˆ๋‹ค. ๋งค๊ฐœ๋ณ€์ˆ˜์™€ ๊ฒฐ๊ณผ ์œ ํ˜•์€ ๊ฐ€๋Šฅํ•œ ๊ฒฝ์šฐ ์ปจํ…์ŠคํŠธ์—์„œ ์ถ”๋ก ๋ฉ๋‹ˆ๋‹ค.

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

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

Example.cs:

// PROJECT-EXAMPLE
System.Func<int, int> twice = value => value * 2;
System.Console.WriteLine(twice(4));

๊ฒฐ๊ณผ:

8

ํ†ต์‚ฌ๋ก 

value => expression / (left, right) => { ... }

์˜ˆ์‹œ 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)
    {
        Func<int, int> square = value => value * value;
        Console.WriteLine(square(4));
    }
}

์˜ˆ์‹œ 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 offset = 3;
        Func<int, int> adjusted = value => { int result = value + offset; return result; };
        Console.WriteLine(adjusted(5));
    }
}

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

โš ๏ธ **GitHub.com Fallback** โš ๏ธ