---
title: "What are the uses of partial class and methods in C# and why are use in C# projects?"  
description: "What are the uses of partial class and methods in C# and why are use in C# projects?"  
author: "Ethan Karla"  
published: 2021-08-25  
canonical: https://answers.mindstick.com/qa/93921/what-are-the-uses-of-partial-class-and-methods-in-c-sharp-and-why-are-use-in-c-sharp-projects  
category: "programming"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# What are the uses of partial class and methods in C# and why are use in C# projects?

What are the uses of [partial class](https://www.mindstick.com/articles/31/partial-class) and [methods in C#](https://www.mindstick.com/interview/34263/what-are-extension-methods-in-c-sharp) and why are use in C# [projects](https://www.mindstick.com/articles/105927/how-to-excel-at-managing-multiple-projects)?

## Answers

### Answer by Ravi Vishwakarma

**C# [Partial](https://www.mindstick.com/blog/78/partial-class-in-dot-net) [Class](https://yourviews.mindstick.com/view/81038/business-class-of-israel-raged-with-coronavirus-pandemic) and method** When we are creating a Production Level Class, then any class can have thousands of Lines of Codes. So when we define a class in a single C# file, then our file can be very big. Also, when we create a class, there are often many such codes, which can be ignored once implemented. That is, there is no need to check those codes ever again. Therefore, in C#, there has been a provision of Contextual Keyword named Partial, using which we can split a class into more than one C# Files and keep the less modified members separate from the more modified members. You can manage and maintain the Production Class in a better way. It is necessary to specify the partial class combination with every Partial Class. The definition of a Partial Class is the same as that of a Normal Class. The only difference is that in Partial Class an extra partial word has been used. **Syntax**

```
     partial class Person
     {
     // Data Members
     //Methods     partial datatype function_name(arguments); // function prototype     }
```

**Example**

```
using System;
namespace CSharpClass
{
    partial class MyClass				// Declaring partial class
    {
        partial void PrintSum(int x, int y); 		// Declaring partial method (Prototype)
        public void Add(int x, int y)
        {
            PrintSum(x, y);
        }
    }
    partial class MyClass
    {
        partial void PrintSum(int x, int y) 		// Implementing partial method (Definition)
        {
            Console.WriteLine('Sum is {0}', x + y);
        }
    }
  public  class Program
    {
        static void Main()
        {
            MyClass  myObj = new MyClass();
            myObj.Add(15, 5);
        }
    }
}
```

**Output:**

```
    Sum is 20
```

\


---

Original Source: https://answers.mindstick.com/qa/93921/what-are-the-uses-of-partial-class-and-methods-in-c-sharp-and-why-are-use-in-c-sharp-projects

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
