PROPERTY
ModelStateDictionary.ErrorCount
Counts recorded model-state errors. Multiple errors can belong to a single field; do not treat the number as the number of invalid fields.
Formal Syntax & Structure
csharp syntaxcsharp
int count = state.ErrorCount;Working Example
Example Snippetcsharp
using System;using Microsoft.AspNetCore.Mvc.ModelBinding;var state = new ModelStateDictionary();state.AddModelError("Name", "Required.");state.AddModelError("Name", "Too short.");Console.WriteLine(state.ErrorCount); // 2