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
1. Immediately after the `var builder = WebApplication.CreateBuilder(args);` line, addthefollowingcode:
82
+
1. Immediately after the `var builder = WebApplication.CreateBuilder(args);` line, addthefollowingcode:
83
83
84
84
```csharp
85
85
builder.Services.AddSingleton<WelcomeService>();
86
86
```
87
-
87
+
88
88
`WebApplication.CreateBuilder` createsanewinstanceofthe `WebApplicationBuilder` classcalled `builder`. The preceding code registers the `WelcomeService` class with the service container with a singleton lifetime.
89
89
90
90
1. Change the `app.MapGet("/", () => "Hello World!");` linetothefollowingcode:
@@ -120,8 +120,8 @@ Now that you have a service, you need to register it with the service container.
120
120
121
121
Yourteamreviewsyourcode, andanotherdevelopersuggeststhatyouuseaninterfaceto register services, as this approach makes the code more flexible and easier to maintain.
122
122
123
-
1. Right-click the *MyWebApp* project in the `Solution Explorer` pane. Select **Add** > **New Folder**. Name the folder *Interfaces*.
124
-
1. Right-click the *Interfaces* folder. Select **Add** > **New File**. Select the file **Interface** file type, and then name the file *IWelcomeService.cs*.
123
+
1. Right-click the *MyWebApp* project in the **Explorer** pane. Select **New Folder**. Name the folder *Interfaces*.
124
+
1. Right-click the *Interfaces* folder. Select **New File**. Name the file *IWelcomeService.cs*.
125
125
1. Replace the contents of *IWelcomeService.cs* with the following code:
0 commit comments