Skip to content

Instantly share code, notes, and snippets.

@AnthonyGiretti
Created November 29, 2022 22:51
Show Gist options
  • Save AnthonyGiretti/f452ae0a025f50ca35daaa0269fa5db5 to your computer and use it in GitHub Desktop.
Save AnthonyGiretti/f452ae0a025f50ca35daaa0269fa5db5 to your computer and use it in GitHub Desktop.
Example of C# 11 List pattern syntax on vowels and consonants arrays
namespace Csharp11Demo.Models;
string[] consonants = { "b", "d", "k", "l" };
string[] vowels = { "a", "e", "o", "l" };
consonants is ["b", "d", "k", "l" ]; // returns true
vowels is ["b", "d", "k", "l"]; // returns false
consonants is ["b", "d", "k"]; // returns false
consonants is [_, "d", "k", _]; // returns true
vowels is [.., "l"]; // returns true
consonants is [_, "d", ..]; // returns true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment