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.
 
Back
Top