Last active
August 29, 2015 14:17
-
-
Save thedom85/3d29899645e319ac094d to your computer and use it in GitHub Desktop.
CSharp_Lambda_validation_Expression_Func
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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