You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Next example is using two delegation classes. Class B has two conflict method names, so one is given an alias name, other is excluded.
classB{publicintMethod1(){return10;}publicvoidMethod2(intp){}publicvoidMethod3(stringq){}}classW:delegateA,delegateB{uses{
B {aliasB_Method1= Method1;excludeMethod2;}}publicvoidSet(Aa){base<A>=a;}publicvoidSet(Bb){base<B>=b;}}
Problem
To use the delegation on various design patterns, we must write a lot of tedious code.
Proposal
To introduce the delegation class in c#.
Example
Class Z use a delegation to class A.
The delegation syntax is written like the inheritance syntax;
Above is expanded to:
Three methods are automatically generated by the compiler.
Next example is using with readonly and override keyword. You must set a delegation in constructor and you can change a method behavior.
Above is expanded to:
Next example is using two delegation classes. Class B has two conflict method names, so one is given an alias name, other is excluded.
Above is expanded to:
Next example is using with inheritance. It is similar to the previous example.
Above is expanded to:
I wish that this proposal makes C# better and it is useful for the people using C#.
The text was updated successfully, but these errors were encountered: