I have a string property that has a maximum length requirement because the data is linked to a database. What exception should I throw if the caller tries to set a string ex
Have a look through mscorlib.dll with Reflector, in a similar situation such as System.String.StringBuilder.Capacity Microsoft use ArgumentOutOfRangeException() similar to:
public int PropertyA
{
get
{
return //etc...
}
set
{
if (condition == true)
{
throw new ArgumentOutOfRangeException("value", "/* etc... */");
}
// ... etc
}
}