> Yeah the only thing is I want name updated if its too long
Huh? You want it updated *then* you want to throw the exception?
That's easy:
set
{
name = value;
if (name == null || name.Length > 14)
throw new Exception(...);
}
There's almost definitely a better way to implement that logic,
however.
> Using your suggestion I could ask the user to re-enter new details but
> I want to handle the issue in the code
In a property is never the correct place to ask the user for more or
different information. Your best bet here is to do something more
robust with user input. Try something like getting the input, then
immediately checking if it's valid.
> Also, with your suggestion name is given value, which may be too long
> I only want name (in this case) to be 0 - 14 chars long
I'm sure you can figure out how to tweak the exact logic (> and <
signs, etc.) to fit what you're trying to do.
Are you sure you understand the symantic meaning of classes and
properties? It seems like you're trying to write procedural (non-OOP)
code and shoehorn it into a class.
Stephan