---
title: "What is a partial class. Give an example?"  
description: "What is a partial class. Give an example?"  
author: "Manasavi Rajpoot"  
published: 2010-11-26  
updated: 2020-09-20  
canonical: https://www.mindstick.com/interview/268/what-is-a-partial-class-give-an-example  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# What is a partial class. Give an example?

A **partial class** is a class whose definition is present in 2 or more files. Each source file contains a section of the class, and all parts are combined when the application is compiled. To split a class definition, use the partial keyword as shown in the example below. Student class is split into 2 parts. The first part defines the study() method and the second part defines the Play() method. When we compile this program both the parts will be combined and compiled. Note that both the parts uses partial keyword and public access modifier.\
\

```
using System;namespace PartialClass{  public partial class Student  {    public void Study()    {      Console.WriteLine("I am studying");    }  }  public partial class Student  {    public void Play()    {      Console.WriteLine("I am Playing");    }  }  public class Demo  {    public static void Main()    {      Student StudentObject = new Student();      StudentObject.Study();      StudentObject.Play();    }  }}
```

## Answers

### Answer by Manasavi Rajpoot

A **partial class** is a class whose definition is present in 2 or more files. Each source file contains a section of the class, and all parts are combined when the application is compiled. To split a class definition, use the partial keyword as shown in the example below. Student class is split into 2 parts. The first part defines the study() method and the second part defines the Play() method. When we compile this program both the parts will be combined and compiled. Note that both the parts uses partial keyword and public access modifier.\
\

```
using System;namespace PartialClass{  public partial class Student  {    public void Study()    {      Console.WriteLine("I am studying");    }  }  public partial class Student  {    public void Play()    {      Console.WriteLine("I am Playing");    }  }  public class Demo  {    public static void Main()    {      Student StudentObject = new Student();      StudentObject.Study();      StudentObject.Play();    }  }}
```


---

Original Source: https://www.mindstick.com/interview/268/what-is-a-partial-class-give-an-example

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
