-
Notifications
You must be signed in to change notification settings - Fork 0
Matching of values
Oliver Zick edited this page Dec 21, 2020
·
3 revisions
static IEnumerable<short> EnumerateShort()
{
for (var value = short.MinValue; value < short.MaxValue; value++)
{
yield return value;
}
}
var match = Match.Always<short>();
// Match all short values, result must be true because all matches must be true
var result = EnumerateShort().All(value => match.Matches(value));
Console.WriteLine($"Match all short values with '{nameof(Match.Always)}' match: {result}");
/* Output:
Match all short values with 'Always' match: True
*/
static IEnumerable<short> EnumerateShort()
{
for (var value = short.MinValue; value < short.MaxValue; value++)
{
yield return value;
}
}
var match = Match.Never<short>();
// Match all short values, result must be false because any match must not be true
var result = EnumerateShort().Any(value => match.Matches(value));
Console.WriteLine($"Match all short values with '{nameof(Match.Never)}' match: {result}");
/* Output:
Match all short values with 'Never' match: False
*/