A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

property to allow positve integers only

Vote:
 

How to set the property to allow positve integers only?

public virutal int Number {get; set;}

How can I customize to allow positve integers only?

#151682
Aug 03, 2016 19:32
Vote:
 

Hi Anusha,

You can decorate your property with Range attribute like this:

[Range(1, int.MaxValue)]
public virtual int Number { get; set; }

Hope this helps!

#151683
Aug 03, 2016 20:33
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.