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:
- Return to Visual Studio.
- Right-click the
ShoppingCart
project and select the “Add, New Folder” option from the menu. - Name the new folder
Services
. - Right-click the
Services
folder and select the “Add, New Item” option from the menu. - Enter “interface” in the “Search” box.
- Select “Interface.”
- Name the file
ICartService
. - Click the “Add” button.
- Enter the following code:
Get hands-on with 1400+ tech skills courses.