Right-click on References and choose Add Reference.To use DataAnnotations namespace in our application, we must add a reference to assembly. We’ll be validating an object of this class. ![]() To keep the code simple and short as much as possible, let’s start by creating a Console application.įirst, create a new class named User and add some properties to it. In this post, I’ll explain how to validate class objects in C# using DataAnnotations. You might be already familiar with this namespace if you have developed MVC apps in. NET, we have a namespace named DataAnnotationsthat has several classes and Attributes to help us to validate data. It prevents the application from processing unwanted inputs that may produce unpredictable results.įortunately, in. Validation is the first and most important step in securing an application.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |