Csharp Intermediate Classes Interfaces And Oop


An in-depth, step-by-step guide to classes, interfaces and object-oriented programming (OOP) with C#

Last updated 2022-01-10 | 4.6

- Work with classes
- constructors
- fields
- properties
- methods and indexers
- Use encapsulation to improve the robustness of the code and reduce the impact of change
- Re-use code using inheritance and composition

What you'll learn

Work with classes
methods and indexers
Use encapsulation to improve the robustness of the code and reduce the impact of change
Re-use code using inheritance and composition
Understand the problems with inheritance and how composition solves these problems
Change the behaviour of an application by extending its code
rather than changing it
Develop loosely-coupled
testable and extensible applications using interfaces

* Requirements

* Basic understanding of C# constructs: variables
* type conversion
* classes
* conditionals and loops


Whether you want to use C# to build web apps, mobile apps, desktop apps or games, understanding C# classes, interfaces and principles of object-oriented programming is crucial.

This course is the second part of Mosh's best-selling C# series and is all about classes, interfaces and object-oriented programming. In essence, you'll learn:

  • How to work with classes, constructors, fields, properties, methods and indexers

  • How to use encapsulation to reduce the impact of change

  • How to improve the robustness of your code

  • How to re-use code using inheritance and composition

  • Why composition is better than inheritance

  • How to build extensible applications using polymorphism

  • How to develop loosely-coupled, extensible and testable applications using interfaces

There are lots of free tutorials and videos on YouTube. Why would you want to take this course?

The answer is simple: quality of teaching.

Mosh is a passionate software engineer with over 13 years of experience developing applications in C#. He is the author of several best-selling C# courses on Udemy and knows how to lead you through a series of baby steps in a logical way.

So, from the very beginning to the very end, you'll be confident that you'll be in good hands and watching every minute of the course, unlike the reading many free tutorials and videos, does not waste your precious time.

Each section is equipped with a balanced mix of theory and practice. At the end of each section you'll get exercises to master the concepts you learn in that section.

And one last reason: all videos are produced with high quality video/audio, to provide you the best learning experience.


This course is the second part of Mosh's complete C# series on Udemy:

  • Part 1: C# Basics for Beginners: Learn C# Fundamentals by Coding 
  • Part 2: C# Intermediate: Classes, Interfaces and Object-oriented Programming
  • Part 3: C# Advanced: Take Your C# Skills to the Next Level


"I’ve actually landed my first job as a Junior software developer. I owe a lot of it to you because your courses have been EXTREMELY helpful. May God bless you and your efforts to create high quality courses. This has really changed my life from working as a security guard and doing websites for free, now I am a professional." -Danish Jafri

"Your courses have given me the confidence to get out of my dead end job and apply for a full time coding job. I am very happy to say that I just finished the job interview and they gave me the job!!!" -Dan Farnell

"Outstanding quality! I have come to learn that all Mosh's courses are top notch. This course is no different! The content is beautifully designed, well organized with great examples, and delivered in a clear and concise manner (with great video and audio quality)! I also loved that this course includes exercises. Fantastic stuff!" -Roger Sæle

"Love it! This guy definitely knows what he's talking about. He strives to make his courses as comprehensive as possible and he teaches you several tricks along the way." -Jeb Watson

"As with all of his courses his passion and love for programming is infectious. He does a great job of intermixing theory with hard examples and cautions with practicality. If you learn better by watching and examples then reading and theory this is a must watch to move beyond the learning the syntax of c#." -Michael Paul

"Excellent course! All of Mosh's courses are very much worth taking if you really want to learn C# in a professional way. Not only does Mosh clearly describe the syntax of the language and explain the language concepts, but he also constantly emphasizes the importance of good programming practices" -Tony Zampini


Mosh (Moshfegh) Hamedani is a passionate software engineer and teacher with 13 years of experience building applications using C# (since the first release of .NET Framework in 2002). Mosh is a full-time developer and what you are going to learn in this course is the result of his day-to-day work as a hardcore programmer along with years of studying,

Mosh's students describe him as a passionate teacher who knows how to take a student on a series of logical steps and enriching them with a great mixed of theory and practice.


This course comes with a 30-day full money-back guarantee. Take the course, go through the lectures, do the exercises, and if you're not happy, ask for a refund within 30 days. All your money back, no questions asked.

So do you want to take your C# skills to the next level? Then take this course now and get started!

Who this course is for:

  • Any C# developer who wants to master classes and interfaces
  • Any C# programmer who wants to better understand object-oriented programming

Course content

8 sections • 45 lectures

What You are Going to Learn Preview 02:42

Who is Your Instructor Preview 01:27

Source Code Preview 00:02

Exercises Preview 00:46

Asking Questions Preview 00:33

Before You Get Started Preview 00:50

Introduction to Classes Preview 13:56

  • What are classes and why we need them
  • What is the difference between a class and object
  • How to create classes, fields and methods
  • The var keyword
  • Static members

Constructors Preview 22:54

Object Initializers Preview 02:20

  • How to quickly initialize objects without a constructor

Methods Preview 23:59

  • What is method signature
  • What is method overloading
  • Method parameter modifiers: params, out and ref
  • Why ref is a smell in the design of C# and why you should avoid it.
  • Defensive programming and how it improves the robustness of your applications.

Fields Preview 09:21

  • Two ways to initialize fields (directly and via constructor) and the pros and cons of each
  • The readonly modifier and how it improves the robustness of your code

Access Modifiers Preview 10:48

  • Public and Private access modifiers
  • What is encapsulation?
  • Why we should declare fields as private and provider public accessors

Properties Preview 16:19

  • What are properties and how to create them
  • A quick way to create a property

Indexers Preview 09:30

  • What are indexers, how they are useful and how to create them
  • The Dictionary type

Summary Preview 7 pages

Exercises Preview 2 pages

Class Coupling Preview 03:45

  • What is class coupling
  • What are tightly coupled and loosely coupled applications like
  • Three ways to reduce coupling

Inheritance Preview 07:54

  • What is inheritance
  • An example of inheritance in a real-world scenario: building an application like Power Point
  • How to represent inheritance using UML
  • How to re-use code using inheritance

Composition Preview 07:27

  • What is composition
  • An example of composition in a real-world scenario: DbMigrator and Logger
  • How to represent composition using UML
  • How to create a composition relationship between classes in C#

Favour Composition over Inheritance Preview 08:48

  • Why inheritance can easily be abused by amateur designers / developers
  • Problems with inheritance hierarchies
  • Why inheritance results in tight coupling between classes
  • How composition provides a more flexible and loosely coupled design

Summary Preview 2 pages

Access Modifiers Preview 22:37

  • Why access modifiers are important and how they help writing better code
  • Examples of public, private, protected, internal and protected internal
  • Why protected breaks encapsulation and it's better to be avoided

Constructors and Inheritance Preview 09:42

  • Rules about constructors in inheritance hierarchies
  • The base keyword and how we can use that to pass control to base class constructors

Upcasting and Downcasting Preview 17:45

  • What is upcasting and down casting
  • Rules about casting an object to a base or derived class reference
  • The as and is keywords
  • StreamReader and ArrayList classes

Boxing and Unboxing Preview 07:09

  • What are value types and reference types
  • What is boxing and unboxing
  • Why boxing and unboxing comes with a performance penalty
  • Why generic lists are better to use than ArrayList

Summary Preview 3 pages

Exercises Preview 3 pages

Method Overriding Preview 17:15

  • What is polymorphism and how we can achieve it by method overriding
  • The virtual and override keywords
  • How to get rid of long switch/case or if/else statements and re-write them in an object-oriented way with polymorphism

Abstract Classes and Members Preview 11:58

  • What are abstract classes and members
  • The abstract and override keywords
  • Rules about abstract classes and inheriting from them
  • When to use abstract classes

Sealed Classes and Members Preview 02:38

  • What are sealed classes and members
  • The sealed modifier

Summary Preview 3 pages

Exercises Preview 3 pages

What is an Interface? Preview 04:35

Interfaces and Testability Preview 25:12

  • Introduction to Unit Testing with MS Tests framework
  • How interfaces improve the testability of your applications

Interfaces and Extensibility Preview 18:15

I'll show you how we can change an application's behaviour without changing its code, simply by using interfaces as extensibility points. I'll also introduce you to the open-closed principle of object-oriented programming.

Interfaces are NOT for Multiple Inheritance Preview 04:26

One of the common misconceptions about interfaces is that they are used for implementing multiple inheritance. This view is fundamentally wrong yet there are many books, videos and posts that make such claim. In this video I'll explain why interfaces got nothing to do with inheritance, single or multiple.

Interfaces and Polymorphism Preview 11:47

Interfaces provide polymorphic behaviour, which is extremely powerful. In this video, you'll see how we can use an interfaces in a polymorphic way to design a loosely-coupled and extensible application.

Summary Preview 3 pages

Exercises Preview 2 pages

Final Words Preview 01:01

My Other Courses Preview 02:02

Get My Other Courses with a Discount Preview 00:20