What Is C#? A Beginner’s Guide to C# 14 and .NET 10

What is C#: a first C# program printing Hello, Jenna! and the .NET 10 runtime version in a VS Code style card

C# (pronounced “C sharp”) is Microsoft’s free, general-purpose programming language for building web apps, APIs, cloud services, desktop apps and Unity games. You write C#, and the .NET platform compiles and runs it on Windows, macOS and Linux. In this tutorial, I’ll explain what is C# in plain English, then have you write and run … Read more >>

Namespace in C#: File-Scoped, using and global using (.NET 10)

Namespace in C#: a StoreApp project tree where the Billing and Shipping folders map to the Lakeview.Store.Billing and Lakeview.Store.Shipping namespaces

Two classes called Order, one for billing and one for shipping, and the compiler needs to know which one you mean. That’s the whole reason namespaces exist. Quick answer: A namespace in C# is a named scope that groups related types and keeps their names unique. Declare it with namespace Lakeview.Store.Billing; and import it elsewhere … Read more >>

Events in C#: Build an Order Service Step by Step (.NET 10)

Events in C#: an OrderPlaced event raised by OrderService runs the audit and email subscribers attached with +=

Our Seattle warehouse team wanted an audit line for every order and an email when a standing desk drops below five units. Events in C# handle that cleanly: the order code announces what happened and never needs to know who’s listening. In this tutorial, I’ll build that order service step by step and show you … Read more >>

How to Convert int to double with 2 Decimal Places in C#

C# 2 decimal places: Math.Round vs F2 code with real output

Prices that print as 25 instead of 25.00 look broken to anyone reading a receipt. The fix for C# 2 decimal places is short: convert the int to a double and call ToString(“F2”), or round the value with Math.Round(value, 2). In this tutorial, I’ll show you every way I handle C# 2 decimal places in … Read more >>

Inheritance in C#: A Field Guide with Real Examples (.NET 10)

Inheritance in C#: override runs Manager.Describe through an Employee reference while new hides Label and runs the Employee version

Payroll code is where I see inheritance used well and abused most. Inheritance in C# lets a derived class reuse and extend a base class: write class Employee : Person, and every Employee gets the members of Person plus its own. In this tutorial, I’ll map out how inheritance in C# really behaves on .NET … Read more >>

Enum in C#: Declare, Convert, Flags and JSON (.NET 10)

Enum in C#: a table of Enum.TryParse with ignoreCase and Enum.IsDefined results for Shipped, shipped, Lost, 42 and 2

Status code 3 means nothing to whoever reads your code next year. Shipped means everything, and the compiler can check it for you. Quick answer: An enum in C# is a value type that gives names to a fixed set of integer constants. Declare it with enum OrderStatus { Pending, Paid, Shipped }, cast it … Read more >>

C# Create Folder If Not Exists (Directory.CreateDirectory Guide)

C# create folder if not exists: Directory.CreateDirectory called twice on Reports202610-OctoberTexas with no exception

Want C# to create a folder only if it doesn’t exist? Call Directory.CreateDirectory(path). It creates the folder when it’s missing and quietly returns the existing one when it’s already there, so no check is needed. In this tutorial, I’ll cover every C# create folder if not exists case I run into: the current directory, folders … Read more >>