In C#, if we have a class ‘Employee‘ and it will have a property called ‘Code‘ that must consist of 7 characters in the following format: (A-Z) + (1-9)+(0-1)+(0001-9999)
for example ‘Code’ = A501234 or Z910002
So if we make a property ‘Code‘ in the Class ‘Employee‘ is there any way to force developer when ‘Code‘ is set, to check if it is in the prev format or at least force him to set it to 7 characters, so that, for example, it can cause compiler or build errors?
Thanks in advance for expected cooperation
Validating parameter values/formats at runtime could also be accomplished using the
Validation Application Block from the MS Enterprise library or something similar.
You would basically specify your validation rules using attributes,
Code snippet from http://msdn.microsoft.com/en-us/library/dd139849.aspx. Don’t know of anything that would check at compile time though.