© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
10 replies
DannyRoastBeef㊙

❔ Can anyone break down this one-line code for me?

builder.Services.AddHttpClient<CatalogueService>(catalogueClient => { catalogueClient.BaseAddress = new Uri(""); });
builder.Services.AddHttpClient<CatalogueService>(catalogueClient => { catalogueClient.BaseAddress = new Uri(""); });


I'm following a tutorial surrounding using HttpClient properly. When adding as a service I noticed a syntax I don't think I've used before and I can't quite make sense of it. I think I understand that I'm setting the base address on the injected
catalogueClient
catalogueClient
but how is it doing it? What is
catalogueClient => { catalogueClient.BaseAddress = new Uri(""); }
catalogueClient => { catalogueClient.BaseAddress = new Uri(""); }
actually doing here?

The parameter is
Action<HttpClient> configureClient
Action<HttpClient> configureClient


Thanks.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,793Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Can anyone explain this piece of code for me please ?
C#CC# / help
2y ago
can somebedy traduce this code for me please?
C#CC# / help
3y ago