From the course: Object-Oriented Programming with C#

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Partial classes

Partial classes

- [Instructor] Now it's time to look at a different way to organize the business logic of our classes. A partial class consists of several different code files that are concatenated into a single file by the compiler. The logic for the class is broken up like this to make it easier to organize business logic and to use compiler flags to choose which part of a class to compile or ignore. Think about making a desktop and web application. Some logic will only work on the desktop and others in the browser, so we break out parts of the class into separate files and only include the correct one when compiling. Let's take a look at how this works. We're going to create a new class called house inside of a folder called map in our source directory. Now that we have the house class, we can use our namespace and begin writing out our partial class. In order to do this, we're going to use the key word partial when defining the class name.…

Contents