Search code examples
windowsblazorroot

Where is the "root" of a Visual Studio project?


I am following Microsoft's tutorial of building a To-Do list with Blazor found here: https://learn.microsoft.com/en-us/training/modules/build-blazor-todo-list/3-exercise-data-binding

I get stuck on the "Build a list of to-do items" part. Steps 2 & 3 are copying code, so it must be step 1 that gives me the error of "The type or namespace name 'TodoItem' could not be found.

Step 1 says to "Create a new TodoItem.cs file at the root of the project with the following C# class." I don't know what the root of the project means (very new to development). Is my location the problem? Where should I move that?

My todoitem.cs file looks like this:

namespace BlazorApp;

public class TodoItem
{
    public string? Title { get; set; }
    public bool IsDone { get; set; } = false;
}

I have tried retyping all 3 steps, copy and pasting all three steps.
Moving "TodoItem.cs" right below (but not as a part of) "Program.cs"
Moving "TodoItem.cs" to Components/Pages as well as to wwwroot.
Removing "public bool IsDone { get; set; } = false;" from my cs file.


Solution

  • Create a new TodoItem.cs file at the root of the project with the following C# class.

    Under "Solution 'YourProject'", there is "YourProject". That is the root.
    Right click it and Add -> New Item.