Repository navigation
KO CSharp Members
Codex edited this page Oct 11, 2026
·
2 revisions
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
public, private, protected, internal, protected internal 및 private protected는 가용성을 지정합니다. static는 유형을 나타내고, readonly은 필드 항목을 제한하고, const은 상수를 지정합니다. 이 숙소는 get, set 또는 init을 사용합니다. 인덱서는 []를 통해 액세스를 제공합니다.
이 예제를 Example.cs로 따로 저장하고 이 페이지의 다른 예제와 독립적으로 실행하세요.
Example.cs:
// PROJECT-EXAMPLE
var item = new Item();
item.Count = 7;
System.Console.WriteLine(item.Count);
class Item { public int Count { get; set; } }결과:
7
sealed class Config
{
private int delay = 100;
public string Name { get; init; } = "default";
public int Delay
{
get => delay;
set => delay = Math.Clamp(value, 0, 5000);
}
}
var config = new Config { Name = "Gather", Delay = 150 };
await WaitAsync(config.Delay);
UO.Print(config.Name);sealed class Counters
{
private readonly Dictionary<string, int> values = new();
public int this[string name]
{
get => values.TryGetValue(name, out int value) ? value : 0;
set => values[name] = value;
}
}
var counters = new Counters();
counters["items"] = 3;
UO.Print(counters["items"].ToString());required에서는 객체가 생성될 때 멤버를 채워야 합니다. 개체 및 컬렉션 초기화 프로그램은 유효한 게임 값 확인을 대체하지 않습니다. 부분 유형 partial은 단일 프로젝트를 컴파일할 때 여러 선언을 결합합니다.
ClassicUO — Bad Newbie & C# Scripts IDE