Alternative to inheriting from string

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Hello,

I would like to write a string-like class that will only allow certain
string values, (for example, specified with a regular expression). I'd
still like it to behave like a string, I just don't want to ensure the
validity of it's value. Since you can't inherit from string, what would be
the best way to approach this?

Mike
 
"The best way" is always relative to the domain of your application, but my
suggestion would be to create a class that wraps around a regular string.
You probably want to implement the IComparable and IConvertible interfaces.
 

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

Back
Top