在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
部分类也可以定义部分方法。部分方法在部分类中定义,但没有方法体,在另一个部分类中执行。在这两个部分类中,都要使用partial关键字。
public partial class MyClass { partial void MyPartialMethod(); } public partial class MyClass { partial void MyPartialMethod() { // Method implementation } }
public partial class MyClass { partial void DoSomethingElse(); public void DoSomething() { Console.WriteLine(“DoSomething() execution started.”); DoSomethingElse(); Console.WriteLine(“DoSomething() execution finished.”); } } public partial class MyClass { partial void DoSomethingElse() { Console.WriteLine(“DoSomethingElse() called.”); } }
DoSomething() execution started.
DoSomethingElse() called.
DoSomething() execution finished.
DoSomething() execution started.
DoSomething() execution finished.
部分类也可以定义部分方法。部分方法在部分类中定义,但没有方法体,在另一个部分类中执行。在这两个部分类中,都要使用partial关键字。
public partial class MyClass { partial void MyPartialMethod(); } public partial class MyClass { partial void MyPartialMethod() { // Method implementation } }
public partial class MyClass { partial void DoSomethingElse(); public void DoSomething() { Console.WriteLine(“DoSomething() execution started.”); DoSomethingElse(); Console.WriteLine(“DoSomething() execution finished.”); } } public partial class MyClass { partial void DoSomethingElse() { Console.WriteLine(“DoSomethingElse() called.”); } }
DoSomething() execution started.
DoSomethingElse() called.
DoSomething() execution finished.
DoSomething() execution started.
DoSomething() execution finished.
|
请发表评论