分割方法-partial method
役割:1つの方法の実装を2つのファイルに書くことができます.
主な役割は次のとおりです.
1.前処理よりも「清潔」な方法を提供
2.簡単なエージェント-イベントモデルの提供
3.「ダミーメソッド」の別のバージョンを提供
例:
file1.cs:
file2.cs
主な役割は次のとおりです.
1.前処理よりも「清潔」な方法を提供
2.簡単なエージェント-イベントモデルの提供
3.「ダミーメソッド」の別のバージョンを提供
例:
file1.cs:
using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace TestCS
{
partial class c1
{
// partial , partical method
// void
//
partial void onSayHello(string msg);
public bool TestMethod(string msg)
{
onSayHello(msg);
return true;
}
}
class Program
{
static void Main(string[] args)
{
c1 c = new c1();
c.TestMethod("It's good day");
}
}
}
file2.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TestCS
{
partial class c1
{
// partial , partical method
// void
//
partial void onSayHello(string msg)
{
Console.WriteLine("xx====" + msg);
}
}
}