Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
설명서 C# · 예시 UO
템플릿은 동시에 값을 확인하고 데이터를 검색할 수 있습니다. 상수, 유형, 속성, 위치, 관계, 목록 및 논리 조합 and, or, not에 대한 템플릿을 사용할 수 있습니다. _는 폐기된 값을 나타냅니다.
and
or
not
_
이 예제를 Example.cs로 따로 저장하고 이 페이지의 다른 예제와 독립적으로 실행하세요.
Example.cs
Example.cs:
// PROJECT-EXAMPLE int value = 15; System.Console.WriteLine(value is > 10 and < 20);
결과:
True
object value = "backpack"; if (value is string { Length: > 0 } name) { UO.Print(name); }
int[] numbers = [1, 2, 3]; string shape = numbers switch { [1, .., 3] => "starts with 1 and ends with 3", [] => "empty", _ => "other" }; UO.Print(shape);
공식 문서: 패턴 일치 - Microsoft Learn.
There was an error while loading. Please reload this page.