C#
Public
Simple Class with Property
Create a small class with properties and instantiate it.
#csharp
#class
#oop
#beginner
C#
using System;
Product product = new()
{
Name = "Keyboard",
Price = 49.99m
};
Console.WriteLine($"{product.Name}: {product.Price:C}");
class Product
{
public string Name { get; set; } = "";
public decimal Price { get; set; }
}
Notes
Auto-properties are the cleanest syntax for simple data objects.