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 >>

Method Overriding in C#: virtual, override, base and new (.NET 10)

Method overriding in C#: through a Payment variable the overridden Fee runs the Card version while the hidden Label runs the base version

If you’ve written a Fee() method in a C# derived class and called it through a base-class variable, you’ve probably watched the base version run anyway, with a CS0108 warning in the build output. That’s because method overriding in C# takes two keywords: virtual on the base method and override on the derived one. Leave … Read more >>

Type Casting in C#: A Program to Demonstrate Every Conversion

Type casting in C#: a table comparing (int) cast, Convert.ToInt32 and int.Parse results for 12.97, 2.5, 3.5, "42", "abc" and null

Type casting in C# changes a value from one type to another. Widening casts like int to long happen implicitly, while narrowing casts like (int)12.97 need explicit syntax and can lose data: that one returns 12, not 13. In this tutorial, I’ll build up a little US shipping calculator and use it to show type … Read more >>

Method Overloading in C# (With Real-Time Examples)

Method overloading in C#: each Calculate call and the overload the compiler picks, with real .NET 10 results

Say you’re writing the checkout for an Austin outdoor store, and method overloading in C# is how one Calculate method takes whole dollars, a price with cents, or a price plus a custom tax rate. Quick answer: declare several methods with the same name but a different number, type or order of parameters. The compiler … Read more >>