Brazor training module todos ambiguity - needs to be singular

Marvin Lynn Roberts 20 Reputation points
2024-11-17T19:23:22.6366667+00:00

@code {

private List<TodoItem> todos = new();

}

From https://learn.microsoft.com/en-us/training/modules/build-blazor-todo-list/3-exercise-data-binding
throws an error. Making todo singular seems to fix the ambiguity.

Am I missing something, or is there simply an error in the code sample?

This question is related to the following Learning Module

Azure Training
Azure Training
Azure: A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.Training: Instruction to develop new skills.
1,819 questions
0 comments No comments
{count} votes

Accepted answer
  1. RNareddy 1,345 Reputation points Microsoft Vendor
    2024-11-18T08:33:02.2966667+00:00

    Hello @Marvin Lynn Roberts ,

    Thank you for reaching out to us on the Q&A platform.

    We have able to successfully execute the code in the module you have mentioned as shown:
    User's image

    User's image

    Output:
    User's image

    We request you to make sure you are using the .NET version 9 and completing the exercise.

    Please Accept Answer and Upvote if the answer is helpful.


1 additional answer

Sort by: Most helpful
  1. Anthonym 0 Reputation points
    2024-11-17T20:25:48.67+00:00

    // older versions of C#

    private List<TodoItem> todos = new List<TodoItem>();

    // Shorthand syntax in C# 9.0 or later

    private List<TodoItem> todos = new();

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.