Created
August 31, 2025 09:46
-
-
Save karenpayneoregon/7ded8f2c980a385a9455794716b8821b to your computer and use it in GitHub Desktop.
C# CommaDelimitedStringCollection
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
| AnsiConsole.MarkupLine("[yellow]Comma delimited full month names[/]"); | |
| CommaDelimitedStringCollection result1 = []; | |
| result1.AddRange(DateTimeFormatInfo.CurrentInfo.MonthNames[..^1]); | |
| Console.WriteLine($"{result1}"); | |
| AnsiConsole.MarkupLine("[yellow]Using an int array[/]"); | |
| int[] items = [1, 2, 3]; | |
| CommaDelimitedStringCollection result2 = new(); | |
| result2.AddRange(items.ToStringArray()); | |
| result2.Add("4"); | |
| Console.WriteLine($"{result2}"); | |
| AnsiConsole.MarkupLine("[yellow]Using DateOnly[/]"); | |
| CommaDelimitedStringCollection results3 = []; | |
| List<DateOnly> dates = [new(2022, 1, 1), new(2023, 2, 14), new(2024, 3, 17), new(2025, 7, 4)]; | |
| foreach (var date in dates) | |
| { | |
| results3.Add(date.ToString()); | |
| } | |
| Console.WriteLine($"{results3}"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment