Replies: 6 comments
-
i don't understand how your first example is different from: class Program {
// using -> private
private readonly TextWriter log = Console.Out;
public Program() { }
public Program(TextWriter log) {
this.log = log;
}
public void Run() {
WriteLine("Starting");
}
} |
Beta Was this translation helpful? Give feedback.
-
@CyrusNajmabadi Looks like it is the public void Run() {
log.WriteLine("Starting");
} |
Beta Was this translation helpful? Give feedback.
-
This can also be accomplished for individual methods via Action<string> WriteLine => log.WriteLine; but the proposal would provide a way to bring everything into scope instead of just a single member. |
Beta Was this translation helpful? Give feedback.
-
If we add access modifiers (e.g. var program = new Program(myLogger);
program.WriteLine("Some string"); |
Beta Was this translation helpful? Give feedback.
-
That's not the purpose of the feature, it should work like |
Beta Was this translation helpful? Give feedback.
-
Fair enough. But if member delegation is more popular, influencing its design might get your proposed feature for free. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
While
using static
is a nice feature, static classes have inherent limitations. I think the same idea can be applied to fields, or even properties. e.g.:I understand this looks a lot like #114, but it's a completely different feature. Unfortunately, the
using
keyword has already too many uses.Also, if #218 is implemented, then it would be better to not have it on the member declaration, but on it's own
using
declaration, e.g.:In the above example, the
instance
keyword is used to specify a member of the current type.Beta Was this translation helpful? Give feedback.
All reactions