You can not ignore the replacement of partial?

The biggest argument I have seen so far for partial classes relates to automatically generated code.

From a Java perspective, I don’t understand why this is simply not possible with abstract classes, can the automatically generated code just be an abstract class with the methods protected abstractthat it expects the user to override

In addition to the automatically generated code cases, every other case that I saw was either extremely rare (and the encoders used only partialas a hack), or it can also be solved with the help of abstractor some other concept that already exists.

+4
source share
2 answers

Inheritance is observed on the compiled assembly, but partialnot. This makes inheritance unsuitable for libraries where you need to strictly control surface area .. NET BCL could never use this, for example.

This is also a hack, because inheritance is not intended to be used to stitch classes. This primarily means a means of creating interchangeability and abstraction.

partialDesigned specifically for this use case. Parts of a partial classcan refer to each other, which is impossible with inheritance.

, , . LINQ to SQL , DataContext . , , , , , .

+8

- . , , .

inheritage, , "".

0

All Articles