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

 About This Book

 Introduction of C# (C Sharp)

 Data Type and Variables

 Logical Expressions and Conditional Statements

 Arrays and Loop Statements

 Data Type Features

 Floating-Point Data Types

 Passing Parameters to Methods

 Execution Environment Class

 Visual C# 2010 Express Edition

 Class Features

 C# Compiler and Intermediate Language

 Compiling C# Source Code Files

 MSBuild - Microsoft Build Engine

 Memory Usages of Processes

 Multithreading in C#

 Async Feature from C# 5

 System.IO.FileInfo Class

 System.Diagnostics.FileVersionInfo Class

 WPF - Windows Presentation Foundation

Partial Classes and Partial Methods

 What Is Partial Class?

 Partial Class Example

What Is Partial Method?

 Partial Method Example

 Outdated Tutorials


 Full Version in PDF/ePUB