KO CSharp Namespaces Extensions - LIHACHTETAN/ClassicUO-Bad-Newbie-CSharp-Scripts-IDE GitHub Wiki
Π£ΠΊΡΠ°ΡΠ½ΡΡΠΊΠ° Β· Π ΡΡΡΠΊΠΈΠΉ Β· English Β· Deutsch Β· FranΓ§ais Β· Italiano Β· EspaΓ±ol Β· ηΉι«δΈζ Β· ζ₯ζ¬θͺ Β· νκ΅μ΄
λ€μμ€νμ΄μ€, μ¬μ© λ° νμ₯ λ°©λ²
namespaceλ μ νμ κ·Έλ£Ήννμ¬ μ΄λ¦μ΄ μ€λ³΅λλ κ²μ λ°©μ§νλ λ° λμμ΄ λ©λλ€. usingμλ λ€μμ€νμ΄μ€κ° ν¬ν¨λκ³ λ³μΉμ μ νμ λν΄ λ€λ₯Έ μ΄λ¦μ μ§μ νλ©° using staticμλ μ μ λ©€λ²κ° ν¬ν¨λ©λλ€. global usingλ μΌλ° νλ‘μ νΈμ λͺ¨λ νμΌμμ μ ν¨ν©λλ€.
κ°λ¨ν μμ (Example.cs)
μ΄ μμ λ₯Ό Example.csλ‘ λ°λ‘ μ μ₯νκ³ μ΄ νμ΄μ§μ λ€λ₯Έ μμ μ λ
립μ μΌλ‘ μ€ννμΈμ.
Example.cs:
// PROJECT-EXAMPLE
using System;
Console.WriteLine("ore".Twice());
static class TextTools { public static string Twice(this string value) => value + value; }
κ²°κ³Ό:
oreore
// PROJECT-EXAMPLE
using System;
using Number = System.Int32;
using static System.Math;
namespace UserTools;
public static class Calculation
{
public static Number Clamp(Number value) => Max(0, Min(100, value));
}
νμ₯ λ©μλλ μΌλ° .cs νλ‘μ νΈμ μ ν©ν μ μ μ νμΌλ‘ μ μΈλ©λλ€. μλ μ ν μ μΈμ λ³κ²½νμ§ μκ³ λ μ μ λ©μλλ₯Ό κ°μ²΄μ λ©€λ²λ‘ νΈμΆν μ μμ΅λλ€. νμ₯ μ½λλ APIκ° κ·Έλ¬ν λ³κ²½μ νμ©νλ κ²½μ° μ λ¬λ κ°μ²΄μ μνλ₯Ό λ³κ²½ν μ μμ΅λλ€. .csxμμλ μ΄λ―Έ μ°κ²°λ νμ₯ νλ‘κ·Έλ¨(μ: LINQ)μ μ¬μ©ν μ μμ΅λλ€. μΌλ° μμ€μ λ€μμ€νμ΄μ€ μ μΈ λ° λΌμ΄λΈλ¬λ¦¬ νμ₯μ λμμΈν©λλ€.
// PROJECT-EXAMPLE
using System;
namespace UserTools;
public static class NumberExtensions
{
public static bool IsPositive(this int value) => value > 0;
}
public static class Example
{
public static bool Run() => (3).IsPositive();
}
곡μ λ¬Έμ: λ€μμ€νμ΄μ€, μ¬μ© λ° νμ₯ λ°©λ² - Microsoft Learn.