C# Tutorials - Herong's Tutorial Examples - v3.32, by Herong Yang
What Is Partial Method?
A quick introduction is provided on 'partial' method, which declares the method definition in one partial class, and method signatures in other partial classes.
What Is Partial Method? A partial method is a method that has the method definition in one partial class and the method signature in other partial classes of the same class.
Partial method signatures are used in partial class source files as references. They will be ignored by the C# compiler.
Partial method signatures and definitions are identified by the keyword "partial".
For example, we can write the entry point Main() and partial method signatures in the first partial class source file A1.cs:
// A1.cs public partial class A { private int size; public static void Main() { ... } // partial method signatures partial void method1(); partial void method2(); partial void method2(); }
And write partial method definitions in the second partial class source file A2.cs:
// A2.cs public partial class A { private float price; // partial method definitions partial void method1() { ... } partial void method2() { ... } partial void method3() { ... } }
Then we can compile them together to generate the executable program, A.exe:
C:\herong>csc /out:A.exe A1.cs A2.cs
Table of Contents
Logical Expressions and Conditional Statements
Visual C# 2010 Express Edition
C# Compiler and Intermediate Language
Compiling C# Source Code Files
MSBuild - Microsoft Build Engine
System.Diagnostics.FileVersionInfo Class
WPF - Windows Presentation Foundation