Search⌘ K

Using Partial Classes to Separate Markup from Code

Learn how to use partial classes with Razor components.

We'll cover the following...

Many developers prefer to separate their markup from their C# fields, properties, and methods. Since Razor components are regular C# classes, they support partial classes. The partial keyword is used to create a partial class. We will use a partial class to move the code block from the RAZOR file to a CS file. We do this as follows:

...