Add and addmodelerror in modelstate

ModelState ModelState1 = new ModelState();
modelstate1. Errors. Add (“cannot be empty”);

//Add a property that does not exist in the key of modelstate
modelstate. Add (“123”, modelstate1);

//Add an error to the property

Modelstate. Addmodelerror (“123”, cannot be empty “);

Read More: