Well basically I'm about to start building a class library containing extension methods for data validation.
I've come to the conclusion that I want to return a bool (determine if the data is correct of not) and a string containing the particular reason why the data isn't valid. As a method can only have one return type, I thought of creating a new class and use it's constructor to return the two pieces of data above.
However this is too problematic as the mini class to hold data would have to be static, however it can't have parameters as a static class. Anyway I could go on.
So I'm looking for suggestions, below is some basic code, I actually though of maybe creating a generic list of type my class, and simply change the return type to list, but there's probably a flaw in this
public static class DataValidation
{
public static bool IsValidEmail(this string email)
{
if (string.IsNullOrEmpty(email))
{
// return a bool = false, and a string with an error message
}
}
}
Advice appreciated.

New Topic/Question
Reply



MultiQuote






|