Introduction
This module provides an introduction to object-oriented programming (OOP), focusing on how to create class definitions and instantiate objects in C#. It compares structured programming to object-oriented programming, examines custom classes in relation to the .NET type system, explores class definitions and constructors, and how to create objects using the new
operator.
Imagine you're working at a non-profit company and that you've been asked to help update some old C# software. The volunteers who created the original apps used structured programming to develop their code. The complexity of the projects has grown over time, so the company wants to transition to OOP, which provides code reusability, modularity, and scalability benefits. The transition to OOP requires a change in mindset and approach. To prepare for the project, you need to gain some experience with basic OOP concepts.
The topics covered in this module include:
- Compare structured and object-oriented programming.
- Examine the .NET type system, the difference between value and reference types, and the benefit of using custom class types.
- Design classes using class definitions and namespaces.
- Create class constructors and instantiate objects using the
new
operator. - Exercise: Create classes and objects in C#.
By the end of this module, you'll be able to create class definitions and instantiate objects using constructors and the new
operator.