Quantcast
Viewing latest article 4
Browse Latest Browse All 7

Answer by CharlesNRice for Generic Null/Empty check for each property of a class

If you sometimes want a bool and sometime you want a list of properties and values I would suggest changing so you return an IEnumerable of type ValidationResult

IF you change your method to use yield returns when you want a bool you can just use the Linq Any() method and it will stop after finding the first one. Using IEnumerable you are not limited to 3 properties like in your class you built.

I agree with everything Adriano Repetti posted and instead of returning false you could just yield return a ValidationResult class with the information you need.


Viewing latest article 4
Browse Latest Browse All 7

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>