Retour au cours

Pattern Matching

C# de Zéro à Héros : Masterclass Complète de Programmation

Filtrage par motif (Pattern Matching)

Le filtrage par motif est un moyen de tester des expressions et d'effectuer des actions si le test réussit.

Motif d'expression Switch

csharp string resultat = obj switch { int i => $"C'est un entier : {i}", string s => $"C'est une chaîne : {s}", _ => "Type inconnu" };