In this case first we will try to take a look at partial class. In the simple terms Partial classes are used when functionality is distributed. When the assembly is compiled, the partial classes gets combined together to form a single class unit. Have you ever thought what happens with the constructors, properties or methods for that matter.
Are these all also gets combined to form a single unit.
Let's take a look at this with simple partial class definition.
Now when this piece of code is compiled it will try to combine MyPartialClass into a single unit. When similar definitions for constructor and other functions are encountered compiler enters in ambiguity to decide which definition to be picked. It generates compile time error.
Are these all also gets combined to form a single unit.
Let's take a look at this with simple partial class definition.
Now when this piece of code is compiled it will try to combine MyPartialClass into a single unit. When similar definitions for constructor and other functions are encountered compiler enters in ambiguity to decide which definition to be picked. It generates compile time error.
We cannot have similar constructor in partial classes. So is methods. Because at compile time partial classes gets combined to form one single unit so it created an ambiguity for constructors and methods.
No comments:
Post a Comment