Skip to content

Instantly share code, notes, and snippets.

@thedom85
Last active August 29, 2015 14:17
Show Gist options
  • Save thedom85/3d29899645e319ac094d to your computer and use it in GitHub Desktop.
Save thedom85/3d29899645e319ac094d to your computer and use it in GitHub Desktop.
CSharp_Lambda_validation_Expression_Func
void Main()
{
Expression<Func<string, bool>> validationString = s => s.Length > 5;
Func<string, bool> validate = validationString.Compile();
//Test Validate:Hello
var result = validate("Hello");
Console.WriteLine("validate(Hello):"+result);
//Test Validate:Good Evening
result = validate("Good Evening");
Console.WriteLine( "validate(Good Evening):"+result);
//Out
//validate(Hello):False
//validate(Good Evening):True
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment