C# Intermediate: Classes, Interfaces and OOP
4.6 (19,862 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
89,928 students enrolled

C# Intermediate: Classes, Interfaces and OOP

An in-depth, step-by-step guide to classes, interfaces and object-oriented programming (OOP) with C#
4.6 (19,862 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
89,928 students enrolled
Created by Mosh Hamedani
Last updated 10/2019
English, French [Auto], 7 more
  • German [Auto]
  • Indonesian [Auto]
  • Italian [Auto]
  • Polish [Auto]
  • Portuguese [Auto]
  • Romanian [Auto]
  • Spanish [Auto]
Current price: $104.99 Original price: $149.99 Discount: 30% off
5 hours left at this price!
30-Day Money-Back Guarantee
This course includes
  • 5.5 hours on-demand video
  • 5 articles
  • 10 downloadable resources
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
Training 5 or more people?

Get your team access to 4,000+ top Udemy courses anytime, anywhere.

Try Udemy for Business
What you'll learn
  • 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
  • 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
Course content
Expand all 45 lectures 06:00:26
+ About this Course
6 lectures 06:21
Source Code
Asking Questions
Before You Get Started
+ Classes
10 lectures 01:49:07

  • 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
Introduction to Classes
  • How to quickly initialize objects without a constructor
Object Initializers
  • 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.
  • 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

  • Public and Private access modifiers
  • What is encapsulation?
  • Why we should declare fields as private and provider public accessors
Access Modifiers
  • What are properties and how to create them
  • A quick way to create a property
  • What are indexers, how they are useful and how to create them
  • The Dictionary type

7 pages
2 pages
+ Association between Classes
5 lectures 27:54
  • What is class coupling
  • What are tightly coupled and loosely coupled applications like
  • Three ways to reduce coupling
Preview 03:45
  • 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
Preview 07:54
  • 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#
  • 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
Favour Composition over Inheritance
2 pages
+ Inheritance - Second Pillar of OOP
6 lectures 57:13
  • 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
Access Modifiers
  • Rules about constructors in inheritance hierarchies
  • The base keyword and how we can use that to pass control to base class constructors
Constructors and Inheritance
  • 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
Upcasting and Downcasting
  • 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
Boxing and Unboxing
3 pages
3 pages
+ Polymorphism: Third Pillar of OOP
5 lectures 31:51
  • 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

Method Overriding
  • What are abstract classes and members
  • The abstract and override keywords
  • Rules about abstract classes and inheriting from them
  • When to use abstract classes
Abstract Classes and Members
  • What are sealed classes and members
  • The sealed modifier
Sealed Classes and Members
3 pages
3 pages
+ Interfaces
7 lectures 01:04:15
What is an Interface?
  • Introduction to Unit Testing with MS Tests framework
  • How interfaces improve the testability of your applications
Interfaces and Testability

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.

Preview 18:15

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 are NOT for Multiple Inheritance

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.

Interfaces and Polymorphism
3 pages
2 pages
+ Bonus: Students' Code Reviews
3 lectures 32:21
StopWatch Exercise
Stack Exercise
Workflow Engine Exercise
  • 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