Which code segment should you use?

You are developing a C# application that includes a class named Product. The following code segment defines
the Product class:

You implement System.ComponentModel.DataAnnotations.IValidateableObject interface to provide a way to
validate the Product object.
The Product object has the following requirements:
The Id property must have a value greater than zero.
The Name property must have a value other than empty or null.
You need to validate the Product object. Which code segment should you use?

You are developing a C# application that includes a class named Product. The following code segment defines
the Product class:

You implement System.ComponentModel.DataAnnotations.IValidateableObject interface to provide a way to
validate the Product object.
The Product object has the following requirements:
The Id property must have a value greater than zero.
The Name property must have a value other than empty or null.
You need to validate the Product object. Which code segment should you use?

A.
Option A

B.
Option B

C.
Option C

D.
Option D



Leave a Reply 2

Your email address will not be published. Required fields are marked *


Roberta

Roberta

Because the Validate() method signature returns IEnumerable, that yield return can be used to lazily generate the results – this is beneficial if some of the validation checks are IO or CPU intensive.