45 - .NET Code & Scripts

Check Argument Class (Miscellaneous)

Open source help class to check arguments of a method. This class C#.NET is used to check the arguments that arrive at a method, validating them. It is an open source class, so you can extend its functionality using existing methods as an example. To use it, please note the following example: static void Main(string[] args) { //CheckArgumentTest string name = “john”; int age = -1; string email = “celeru@hotmail”; bool ret = CheckArgumentTest(name, age, email); }

private static bool CheckArgumentTest(string name, int age, string email) { bool ret; try { Check.Argument.IsNotEmpty(name, "name"); //CheckArgument Example Check.Argument.IsNotOutOfRange(age, 18, 99, "age"); //CheckArgument Example Check.Argument.IsNotValidEmail(email, "email"); //CheckArgument Example ret = true; } catch (Exception ex) { Console.WriteLine(ex.Message); ret = false; } return ret; } SOURCE URL