// older versions of C#
private List<TodoItem> todos = new List<TodoItem>();
// Shorthand syntax in C# 9.0 or later
private List<TodoItem> todos = new();
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
@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
// older versions of C#
private List<TodoItem> todos = new List<TodoItem>();
// Shorthand syntax in C# 9.0 or later
private List<TodoItem> todos = new();
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:
Output:
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.