Pages

Topics

Tools

↑↓navigate↵openescclose

C# guides

Every published C# guide, newest first, with practical examples you can copy into your own project.

3,965 guides across 14 topics

Topics

Latest C# guides

Diagram showing C# private protected access limited to derived classes within the same assembly.
C#

C# Private Protected: Syntax and Usage

c# private protected: Learn how C# private protected restricts access to derived types within the same assembly, with syntax, examples, and common pitfalls.

access modifiersinheritanceC# languageencapsulation
Illustration of the C# internal keyword controlling visibility within an assembly boundary.
C#

C# Internal Keyword: Scope and Assembly Boundaries

c# internal keyword: Learn how the C# internal keyword limits visibility to a single assembly, and how to use it with InternalsVisibleTo for testing and modular design.

C#access modifiersassemblyencapsulation
A visual representation of the C# protected keyword showing a base class and derived class with a shield symbol indicating limited access.
C#

Understanding the C# Protected Keyword

Learn how the C# protected access modifier controls member access in inheritance, how it compares with protected internal and private protected, and when to use it in class design.

C# Access ModifiersInheritanceClass DesignEncapsulation
Illustration of a C# class with a locked private field and a public method providing controlled access.
C#

C# Private Keyword: Scoping Members Correctly

c# private keyword: Understand the C# private keyword: how it restricts access, where it applies, and how it supports encapsulation with practical examples.

access modifiersencapsulationC# classesprivate members
A stylized C# code editor showing a public access modifier applied to a method, with a visible key or lock metaphor.
C#

C# Public Keyword: Scope and Access Control

Understand the C# public keyword, its role in access control, interactions with other modifiers, and practical implications for API design.

access modifiersC# scopeencapsulationmember visibility
C# code with access modifiers like public, private, protected, and internal highlighted.
C#

C# Access Modifiers: Syntax and Practical Usage

Learn how C# access modifiers control visibility and encapsulation, including public, private, protected, internal, protected internal, and private protected, with practical examples and common mistakes.

C#Access ModifiersEncapsulationObject-Oriented Programming
Illustration of a C# class diagram showing a protected constructor symbol, representing restricted object creation through inheritance.
C#

C# Protected Constructor Usage and Scenarios

Protected constructors in C# control who can call a constructor: the containing class and derived classes. See syntax, inheritance behavior, factory usage, and common mistakes.

ConstructorsInheritanceAccess ModifiersAbstract Classes
Diagram illustrating a C# class with a private constructor preventing external instantiation, shown as a lock on the constructor.
C#

C# Private Constructor Usage and Patterns

c# private constructor: Learn when and how to use a private constructor in C#: control instantiation, implement singletons, and support factory methods with practical...

C# constructorsSingleton patternstatic classesfactory methods
C# primary constructor syntax shown as a compact class declaration with parameters
C#

C# Primary Constructor: Syntax and Use Cases

Learn how C# primary constructors work, when they simplify code, and where they cause maintenance problems.

primary constructorsC# 12object initializationrecord types
A visual representation of C# constructor execution order showing the sequence of base and derived constructor calls.
C#

C# Constructor Execution Order

Understand the exact order in which C# constructors run, including field initializers, base constructor calls, static constructors, and constructor chaining.

constructorinheritanceobject initializationruntime behavior