0% found this document useful (0 votes)
23 views2 pages

Ultimate C# Masterclass - Pag 9 and 10

This document covers key concepts in C# classes including access modifiers, constructors, methods, encapsulation, overloading, expression-bodied methods, the 'this' keyword, optional parameters, validation of constructor parameters, readonly and const, properties, and object initializers. It discusses how to define these features in classes and the rules and benefits of using them. The document is an overview of important object-oriented programming principles in C#.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views2 pages

Ultimate C# Masterclass - Pag 9 and 10

This document covers key concepts in C# classes including access modifiers, constructors, methods, encapsulation, overloading, expression-bodied methods, the 'this' keyword, optional parameters, validation of constructor parameters, readonly and const, properties, and object initializers. It discusses how to define these features in classes and the rules and benefits of using them. The document is an overview of important object-oriented programming principles in C#.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

● Public and private access modifiers

● What the default access modifier for fields is

Custom constructor
● How to define custom constructors in a class
● What the recommended naming for fields is

C# restriction on code outside classes. Top-level statements


● Whether C# code can be defined outside classes or if it must always be contained within
one
● What top-level statements are

Methods in classes
● How to define methods in classes
● How methods should be named
● The rule of thumb we can use to find out what the default access modifiers in C# are

Encapsulation
● What encapsulation is
● How is encapsulation different from data hiding
● The benefits of using encapsulation

Methods overloading
● What methods overloading is
● What rules we must follow when defining many methods with the same name in a class
● How to quickly create a constructor using Visual Studio

Constructors overloading. Calling one constructor from another


● How to overload constructors
● How to call one constructor from another using the “this” keyword

Expression-bodied methods
● How to make methods shorter by converting them to expression-bodied methods
● The difference between a statement and an expression
"this" keyword (current instance reference)
● How to use the “this” keyword to refer to the current instance of a class

Optional parameters
● How to define optional parameters
● How to set the default value of a parameter

Validation of constructor parameters


● How to validate the constructor parameters
● The purpose of the nameof expression
● Why having public fields is risky

Readonly and const


● How to prevent a field from being modified
● What immutable objects are
● The difference between readonly and const

Limitations of fields. A need for properties


● The limitations of fields
● How can those limitations be addressed using methods
● Why we need properties

Properties
● What properties are
● What a backing field of a property is
● What accessors are
● What the differences between fields and properties are
● When should we use fields, and when properties

Object initializer
● What object initializers are
● The purpose of the init accessor

You might also like