我在网上搜索但在定义部分类时没有找到有关约束/规则的任何有用信息,我的意思是所有类都可以命名为 Partial 还是某些类不能命名?静态类可以是部分的和所有这些东西,请解释清楚我在面试中被问到这个问题,但我没有任何答案。我真的很想深入了解这一点,我曾经在msdn中找到了一些用于定义部分方法的规则,例如
1. Partial method declarations must begin with the contextual keyword
2. partial and the method must return void.
3. Partial methods can have ref but not out parameters.
4. Partial methods are implicitly private, and therefore they cannot be virtual.
5. Partial methods cannot be extern , because the presence of the body determines whether they are defining or implementing.
6. Partial methods can have static and unsafe modifiers.
7. Partial methods can be generic.
8. Constraints are put on the defining partial method declaration, and
may optionally be repeated on the implementing one.
9. Parameter and type parameter names do not have to be the same in the
implementing declaration as in the defining one.
10. You can make a delegate to a partial method that has been defined and implemented, but not to a partial method that has only been defined.
上课也有规定吗...
谢谢小伙子