Quantcast
Channel: Generic Null/Empty check for each property of a class - Code Review Stack Exchange
Browsing latest articles
Browse All 7 View Live

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 Article



Image may be NSFW.
Clik here to view.

Answer 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 Article

Answer 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 Article

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 ValidationResultIF you change your method to use yield...

View Article

Answer 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 Article


Answer 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 Article

Generic 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
Browsing latest articles
Browse All 7 View Live




Latest Images