Skip to content

Instantly share code, notes, and snippets.

View karenpayneoregon's full-sized avatar
🎯
Focusing

Karen Payne karenpayneoregon

🎯
Focusing
View GitHub Profile
@karenpayneoregon
karenpayneoregon / Program.cs
Created December 19, 2025 14:48
C# switch's
internal partial class Program
{
static void Main(string[] args)
{
SwitchSamples.Greeting();
Console.WriteLine();
SwitchSamples.GradesTuple();
Console.WriteLine();
SwitchSamples.GroupBook();
}
internal class Program
{
static void Main(string[] args)
{
string userInput = Console.ReadLine();
Console.WriteLine(Convert.ToInt32(userInput));
Console.ReadLine();
@karenpayneoregon
karenpayneoregon / Program.cs
Created December 18, 2025 15:22
December 17 refactored code
using System.Text.Json;
namespace WorkingWithArrays;
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Press ENTER to exit");
@karenpayneoregon
karenpayneoregon / MockedData.cs
Last active December 17, 2025 20:04
decimals for teaching
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 = [
@karenpayneoregon
karenpayneoregon / MockedData.cs
Created December 17, 2025 16:25
Working with decimal arrays
using System.Text.Json;
namespace WorkingWithArrays.Classes;
internal class MockedData
{
public static decimal[] GetDecimals()
=>
[
99.40m, 98.62m, 98.13m, 96.31m, 85.59m, 78.95m, 62.73m, 58.23m, 57.36m, 57.03m,
@karenpayneoregon
karenpayneoregon / Person.cs
Created December 11, 2025 13:36
SetsRequiredMembers
[method: SetsRequiredMembers]
public record Person(string FirstName, string LastName, DateOnly BirthDate)
{
public int Id { get; set; }
public required string FirstName { get; set; } = FirstName;
public required string LastName { get; set; } = LastName;
public required DateOnly BirthDate { get; set; } = BirthDate;
}
public readonly struct EllipsisNumericFormattable<T> : IFormattable where T : struct, IFormattable
{
private readonly T _value;
private readonly int _width;
private readonly char _paddingChar;
public EllipsisNumericFormattable(T value, int width, char paddingChar)
{
_value = value;
_width = width;
@karenpayneoregon
karenpayneoregon / Category.cs
Last active November 21, 2025 17:02
Demonstrates the use of the `with` expression
public class Category
{
public int Id { get; set; }
public required string Name { get; set; }
}
var $debugHelper = $debugHelper || {};
$debugHelper = function () {
const debugStyleId = "debugger-inline-style";
function addCss() {
if (document.getElementById(debugStyleId)) return; // prevent duplicates
const style = document.createElement("style");
style.id = debugStyleId;