Last active
December 17, 2025 20:04
-
-
Save karenpayneoregon/3b56809e8b9d68d004a8122f5143c330 to your computer and use it in GitHub Desktop.
decimals for teaching
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static decimal[] GetDecimals() | |
| => | |
| [ | |
| 99.40m, 98.62m, 98.13m, 96.31m, 85.59m, 78.95m, 62.73m, 58.23m, 57.36m, 57.03m, | |
| 50.41m, 49.46m, 35.86m, 30.07m, 29.84m, 27.56m, 25.73m, 17.10m, 13.95m, 10.32m | |
| ]; | |
| public static void LambdaWhereLocalArray() | |
| { | |
| decimal[] values = [ | |
| 99.40m, 98.62m, 98.13m, 96.31m, 85.59m, 78.95m, 62.73m, 58.23m, 57.36m, 57.03m, | |
| 50.41m, 49.46m, 35.86m, 30.07m, 29.84m, 27.56m, 25.73m, 17.10m, 13.95m, 10.32m | |
| ]; | |
| List<decimal> queried1 = values.Where(x => x > 50m).ToList(); | |
| List<decimal> queried2 = values.Where(x => x is >= 50m and <= 80m).ToList(); | |
| List<decimal> filtered = []; | |
| for (int Index = 0; Index < values.Length; Index++) | |
| { | |
| if (values[Index] >= 50m && values[Index] <= 80) | |
| { | |
| filtered.Add(values[Index]); | |
| } | |
| } | |
| var areEqual = queried2.SequenceEqual(filtered); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment