Search
Get Started
C
C#
•
3y ago
joeystdio
✅ Why return IServiceCollection in an extension method?
Is there any reason why not to make the method void instead
?
C#
Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,010
Members
View on Discord
Was this page helpful?
Yes
No
P
Pobiega
•
9/15/23, 8:16 AM
so it can be chained
J
joeystdio
OP
•
9/15/23, 8:16 AM
of course
P
Pobiega
•
9/15/23, 8:17 AM
some people really like to do
services .AddSomething() .AddSomethingElse() .AddAthirdThing();
services .AddSomething() .AddSomethingElse() .AddAthirdThing();
P
Pobiega
•
9/15/23, 8:17 AM
(I
'm one of those people
)
J
joeystdio
OP
•
9/15/23, 8:17 AM
I never used chaining so didn
't thought about that
P
Pobiega
some people really like to do ```cs services .AddSomething() .AddSomethingEl...
J
joeystdio
OP
•
9/15/23, 8:17 AM
Yeah looks clean as well
J
joeystdio
OP
•
9/15/23, 8:18 AM
Thanks
!
T
Tvde1
•
9/15/23, 8:18 AM
this is often called the
"fluent
" or
"builder
" pattern
https://dzone.com/articles/fluent-builder-pattern
P
Pobiega
•
9/15/23, 8:18 AM
it does break when you end up with the ones that return a specialized builder
, like AddAuthorization etc
P
Pobiega
it does break when you end up with the ones that return a specialized builder, l...
J
joeystdio
OP
•
9/15/23, 8:19 AM
Yes
T
Thinker
•
9/15/23, 8:20 AM
$close
T
Thinker
$close
M
MODiX
•
9/15/23, 8:20 AM
Use the
<
/
c
l
o
s
e
:1007753098107813888
> command to mark a forum thread as answered
P
Pobiega
•
9/15/23, 8:20 AM
he did
, we juist re
-opened it by writing
services
.
AddSomething
()
.
AddSomethingElse
()
.
AddAthirdThing
();
services
.
AddSomething
()
.
AddSomethingElse
()
.
AddAthirdThing
();