Class for storing fixed width strings including validation

M

Mark Smith

Hi Group,

Are there any examples of class for storing fixed width number strings
such as phone number and social security numbers.

This class would do thing like valid that the number is all integers
or hex and confirm that the number is the correct length. I

f the number is to short return an error or not store the number, etc.

I have a lot of fixed width number string I need to store.

At the moment each string I valid date the ranges etc in each section.

It would be nice to have a class that handles all this for me.

Any suggestion on finding one.

Thanks

Mark
 
J

Justin Rogers

Sorry, the class you are looking for doesn't exist. As of Whidbey WinForms
and ASP .NET both support a masked edit box I believe (I know WinForms
does), so you can validate the input in that manner before it ever gets into
your
collections.

You are look for a fairly specialized tool here. You need to specify a minimum
length, some sort of format string, and you need some sort of error reporting
and
feedback. This isn't normally the type of classes that are implemented in the
BCL
because of the many different ways they could be implemented, considerations
for performance of a generic versus specialized method, and the relatively small
amount of code required to implement this yourself.

If you need help come back and let us know, perhaps with some sample source
code of your attempt.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top