Answer by dfhwze for Generic Null/Empty check for each property of a class
If you decide to go the generic way, without applying attributes on your properties, we could build further on Adriano Repetti's answer. My starting point is the IsNullOrEmpty method, which is invoked...
View ArticleAnswer by Stacy Dudovitz for Generic Null/Empty check for each property of a...
There are several problems with the answers here, most notably that the original question doesn't seem to be answered, namely, that we want to create a clone a class with ONLY the fields that are set...
View ArticleAnswer by Ron Beyer for Generic Null/Empty check for each property of a class
This is an interesting approach but I would prefer to do this via attributes, for example lets take the following sample class:public class SampleClass { public int Property1 { get; set; } public bool...
View ArticleAnswer 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 ValidationResultIF you change your method to use yield...
View ArticleAnswer by t3chb0t for Generic Null/Empty check for each property of a class
@Adriano Repetti was faster with his list of issues ;-) so I'll just post an alternative soltuion where you can have everyting in only one linq query using the All extension. It will stop as soon as...
View ArticleAnswer by Adriano Repetti for Generic Null/Empty check for each property of a...
First of all I'd reduce indentation. It makes your code really too hard to read. Doing that you will see it may be simplified.First of all try/catch: a catch-all block where you rethrow the exception...
View ArticleGeneric Null/Empty check for each property of a class
I have created a method to check for null/empty values of class properties and if any null property is found I'm stopping the checking process and returning the result as true. I've used a solution...
View Article