Method Chaining #577
Replies: 4 comments
-
What happens when the type of the property is a delegate? static class C
{
public static Action<object> P { get; set; }
}
…
Action<object> a = o => {};
C.P(a); This is already valid syntax, which gets the property and then invokes the delegate, passing |
Beta Was this translation helpful? Give feedback.
-
Proposed here with a slightly different syntax. |
Beta Was this translation helpful? Give feedback.
-
And here. |
Beta Was this translation helpful? Give feedback.
-
I really don't see how: Console
.WriteLine("Hello World")
.BackgroundColor(ConsoleColor.Green)
.WriteLine("Hello Green World")
; is more readable, or in any way offers any other benefits over existing code: using static System.Console;
...
WriteLine("Hello World");
BackgroundColor = ConsoleColor.Green;
WriteLine("Hello Green World"); Further, to my mind at least, the purpose of method chaining isn't just to save typing and to join up a set of methods via |
Beta Was this translation helpful? Give feedback.
-
I would like to request that C# allow additional invocations on methods that return void. Related, I would like to be able to call Setter members as if they were functions.
If the Method is an instance method, the instance method should be "returned" by void.
If the Method is a static method, the static class should be "returned" by void.
For example:
should be able to be written as:
This would bring Fluent APIs to the existing C# codebases.
This would not break existing code because in existing code, you cannot "dot" off of void returns.
Beta Was this translation helpful? Give feedback.
All reactions