C# Intermediate: Classes, Interfaces and OOP

An in-depth, step-by-step guide to classes, interface and object-oriented programming, with many real-world examples.
4.6 (1,859 ratings)
Instead of using a simple lifetime average, Udemy calculates a
course's star rating by considering a number of different factors
such as the number of ratings, the age of ratings, and the
likelihood of fraudulent ratings.
10,227 students enrolled
$19
$50
62% off
Take This Course
  • Lectures 45
  • Length 6 hours
  • Skill Level Intermediate Level
  • Languages English
  • Includes Lifetime access
    30 day money back guarantee!
    Available on iOS and Android
    Certificate of Completion
Wishlisted Wishlist

How taking a course works

Discover

Find online courses made by experts from around the world.

Learn

Take your courses with you and learn anywhere, anytime.

Master

Learn and practice real-world skills and achieve your goals.

About This Course

Published 2/2015 English

Course Description

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 a best-selling author on Udemy in the category of C# 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 more importantly, you can submit your code for review. Mosh gives you a personalized review and tips to improve the quality of your code. Do you get that from free tutorials?

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


What others say

"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



About Mosh

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.


100% money-back guarantee

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!



What are the requirements?

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

What am I going to get from this course?

  • 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

What is the target audience?

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

What you get with this course?

Not for you? No problem.
30 day money back guarantee.

Forever yours.
Lifetime access.

Learn on the go.
Desktop, iOS and Android.

Get rewarded.
Certificate of completion.

Curriculum

Section 1: About this Course
What You are Going to Learn
Preview
02:42
Who is Your Instructor
Preview
01:27
Source Codes
Article
Exercises
Article
Asking Questions
02:58
Section 2: Classes
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
22:54
02:20
  • How to quickly initialize objects without a constructor
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.
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

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

Summary
7 pages
Exercises
2 pages
Section 3: Association between Classes
03:45
  • What is class coupling
  • What are tightly coupled and loosely coupled applications like
  • Three ways to reduce coupling
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
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#
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
2 pages
Section 4: Inheritance - Second Pillar of OOP
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
09:42
  • Rules about constructors in inheritance hierarchies
  • The base keyword and how we can use that to pass control to base class constructors
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
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
3 pages
Exercises
3 pages
Section 5: Polymorphism: Third Pillar of OOP
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

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
02:38
  • What are sealed classes and members
  • The sealed modifier
Summary
3 pages
Exercises
3 pages
Section 6: Interfaces
What is an Interface?
04:35
25:12
  • Introduction to Unit Testing with MS Tests framework
  • How interfaces improve the testability of your applications
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.

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.

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
3 pages
Exercises
2 pages
Section 7: What's Next?
Final Words
01:01
My Other Courses
02:02
Get My Other Courses with a Discount
Article
Stay in Touch
1 page
Section 8: Bonus: Students' Code Reviews
StopWatch Exercise
12:21
Stack Exercise
07:24
Workflow Engine Exercise
12:36

Students Who Viewed This Course Also Viewed

  • Loading
  • Loading
  • Loading

Instructor Biography

Mosh Hamedani, Passionate Software Engineer and Best-selling Author

Moshfegh Hamedani is a passionate and creative software engineer with a strong focus on pragmatism and simplicity. He started programming at the age of seven on a Commodore 64. Later, during his high school years, he started learning C and C++ . In 2002, along with the first release of .NET, he shifted his focus to C#. Since then he has been involved in the design and implementation of numerous software projects, including modern web applications, mobile apps, desktop applications and frameworks.

Aside from his career as a software engineer, he truly enjoys sharing his knowledge with others. Since his early twenties, he has been teaching courses and running workshops on C#, ASP. NET, object-oriented programming and clean coding. He is author of 6 best-selling courses on Udemy and more will be coming soon.

Mosh has a Master of Science in Network Systems and a Bachelor of Science in Software Engineering. He is also a Microsoft Certified Application Developer, Technology Specialist (Web Applications) and Professional.

Outside the software world, Mosh is a photographer, a pianist and a passionate Latin dancer.

Ready to start learning?
Take This Course