Why is a form class in a Windows Form application declared partial?

  • Can someone say why and why it is declared as partial?
  • What is its use?
  • Can this be declared without partial?
+3
source share
3 answers

It is declared partial because VS.NET will put the "design" code in a separate .cs file, which is actually part of the same class at compile time.

Form1.cs, Form1.Designer.cs . VS.NET, . , , .

, # . ( ) , , - , , - .

" ", , , .cs , VS.NET . , ( ) (, T4).

""?

+5

, . , , partial.

0

The form design has its code in another .cs file, and its events and other code (which you encode) are stored in another .cs file. But both files are declared using the same class name, i.e. the name of your form. That is why it is marked as "partial." This is true for ASP.NET pages if you use code.

0
source

Source: https://habr.com/ru/post/1723445/