This question has already been answered:

I am developing a program, writing code in Form1.cs, and there is a lot of code, I have to scroll the page up and down. Is it possible to break the code into several files? For example, Form1.cs Form1_code1.cs Form1_code2.cs But so that the code of each other is seen without any context throwing. Tell the template how to implement it or read the link.

Marked as a duplicate by the participants Andrey NOP , Rostyslav Kuzmovych , Viktor Tomilov , Community Spirit 13 Feb '18 at 10:29 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

    2 answers 2

    Yes you can. The partial keyword is specifically used for this.

    Shared Classes and Methods (C # Programming Guide)

      Announcing in different files the same class and next to the word. class write partial. C # supports partial classes. To declare a partial class, you need to add the partial modifier to the class declaration. In second grade it looks identical. For example.

      FirstPart.cs

       partial class SomeClass { // Определение класса 1 } 

      SecondPart.cs

       partial class SomeClass { // Определение класса 2 } 

      This question is already on the forum. The answer from there https://ru.stackoverflow.com/questions/173/ How to-declare one class-in-several-files-in-