I've created a method that performs some validations against an XML Hierarchy that is dynamically generated by another Class in Javascript text during run time.
My method currently returns either True or False, which is helpful for anyone using my Class but I'd like to also return more informative information since there may be several reasons that can throw a False message.
At first I thought to change the return type from bool to some Generic Collection type having a String key and Boolean value I don't know if this is the best approach.
What is the Best Practice in this case?
toString(boolean b) returns a String object representing the specified boolean. If the specified boolean is true, then the string "true" will be returned, otherwise the string "false" will be returned.
Boolean functions must return something boolean. Non-boolean functions must not return something boolean. Comparisons, logical AND/OR, and true/false macros are bool.
Return Value:It returns true, if the Boolean objects represent the same value. It returns false, if the Boolean objects represent different value.
Make a class like
public class ValidationResponse
{
public bool Successful { get; set; }
public string Information { get; set; }
}
and return object of ValidationResponse
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With