Creating the ICartService Interface and CartService Class

Learn how to create and register a service in Blazor WebAssemblly using DI.

Creating the ICartService interface

We need to create an ICartService interface. We do this as follows:

  1. Return to Visual Studio.
  2. Right-click the ShoppingCart project and select the “Add, New Folder” option from the menu.
  3. Name the new folder Services.
  4. Right-click the Services folder and select the “Add, New Item” option from the menu.
  5. Enter “interface” in the “Search” box.
  6. Select “Interface.”
  7. Name the file ICartService.
  8. Click the “Add” button.
  9. Enter the following code:

Get hands-on with 1200+ tech skills courses.