Created
March 5, 2025 04:25
-
-
Save cdock1029/26bfbe1cae3af1fd8cd8f6b09065c965 to your computer and use it in GitHub Desktop.
Converter accessing previous data
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
| @page "/demo" | |
| <h2>Items Diff</h2> | |
| <div class="flex items-end"> | |
| @foreach ((int idx, int n) in _nums.Index()) | |
| { | |
| <div class="mx-4 w-20"> | |
| @{ | |
| int diff = @Diff(_nums, idx); | |
| } | |
| <span>Diff = @diff</span> | |
| <div class="@(diff > 0 ? "bg-green-400" : "bg-red-400") flex flex-col items-center justify-end text-2xl" | |
| style="height: @(n)0px;"> | |
| @n | |
| </div> | |
| </div> | |
| } | |
| </div> | |
| @code { | |
| private readonly List<int> _nums = [24, 13, 15, 20, 17, 25]; | |
| static int Diff(List<int> list, int idx) | |
| { | |
| return idx == 0 ? list[0] : list[idx] - list[idx - 1]; | |
| } | |
| } |
Author
cdock1029
commented
Mar 5, 2025

Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment