Skip to content

Instantly share code, notes, and snippets.

@testfirstcoder
Created February 26, 2016 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save testfirstcoder/44a79bd606269a4874de to your computer and use it in GitHub Desktop.
Save testfirstcoder/44a79bd606269a4874de to your computer and use it in GitHub Desktop.
Get value from DataAnnotations.StringLengthAttribute
int GetStringLengthAttributeValue<T>(string property)
{
return typeof(T)
.GetProperty(property)
.GetCustomAttribute<StringLengthAttribute>()
.MaximumLength;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment