B
Berryl Hesh
Requirements for a field that represents an EmployeeNumber:
· The field is always 6 characters long, and is stored as a 'string'
in the db
o All characters must be digits
§ Regex pattern?
o If the number of digits in the EmployeeNumber is less than 6
characters, pad the number with leading 0's (i.e., 12 == '000012', 6728 ==
'0006728').
§ String.Format({"06", empNumber) ?
o The non-padded number should be easily extractable
§ empNbrString.Substring(_firstCharGreaterThanZero(empNbrString))
(ie, '006728' == 6728, '000012' == 12)
Each requirement sounds relatively easy to do by brute force, but I'm sure
there is a more elegant approach some of you experts have used before.
Would you use a custom format provider? That may be overkill for the
employee, but I have similar formatting requirements for projectNumbers
which are complicated by the fact that different formats may apply to the
same project, depending on the organizational point of view.
Thanks for the Guidance
· The field is always 6 characters long, and is stored as a 'string'
in the db
o All characters must be digits
§ Regex pattern?
o If the number of digits in the EmployeeNumber is less than 6
characters, pad the number with leading 0's (i.e., 12 == '000012', 6728 ==
'0006728').
§ String.Format({"06", empNumber) ?
o The non-padded number should be easily extractable
§ empNbrString.Substring(_firstCharGreaterThanZero(empNbrString))
(ie, '006728' == 6728, '000012' == 12)
Each requirement sounds relatively easy to do by brute force, but I'm sure
there is a more elegant approach some of you experts have used before.
Would you use a custom format provider? That may be overkill for the
employee, but I have similar formatting requirements for projectNumbers
which are complicated by the fact that different formats may apply to the
same project, depending on the organizational point of view.
Thanks for the Guidance