Repository navigation
IT CSharp Patterns
Codex edited this page Oct 11, 2026
·
2 revisions
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
Il modello controlla contemporaneamente il valore e può recuperare i dati. Sono disponibili modelli per costanti, tipi, proprietà, posizioni, relazioni, elenchi e combinazioni logiche and, or, not. _ denota un valore scartato.
Salvare questo esempio separatamente come Example.cs. Eseguirlo indipendentemente dagli altri esempi di questa pagina.
Example.cs:
// PROJECT-EXAMPLE
int value = 15;
System.Console.WriteLine(value is > 10 and < 20);Risultato:
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);Documentazione ufficiale: Corrispondenza dei modelli - Microsoft Learn.
ClassicUO — Bad Newbie & C# Scripts IDE