Extending the string class?

  • Thread starter Thread starter Don
  • Start date Start date
I don't know but I read somewhere that the string
like
dim x as string in vb.net
is implemente in some special way to act like most people expect a built-in
data type to work and I would think you couldn't easily extend it. Not
sure.

Maybe the stringbuilder could be.

Of course you could include a string variable as a member varible in your
own class and do some manipulation to it that way--I know not exactly what
you were looking for though.

I would like to know the answer to this also.

Shane
 
Hi Don,

Where you able to find something that not is in one of the string methods or
whatever the name is, and also not in one of those endles Microsoft Basic
string functions.

I am also curious what it is.

Cor
 
I just wanted to add a special formatting function for making sure the
string is valid for putting into an SQL query (empty strings are returned as
"Null", apostrophes are doubled up, etc.) and thought it would be neat to
have it as a method of the string object. But, as someone else already
mentioned, it appears that the String class cannot be inherited.

- Don
 
again.

class mystring
private _myinternalstring as string

sub new(s as string)
_myinternalstring=s)
end sub
end class

could be an answer to sort of fake it....

you could add what you like and also make your own value property and from
there map each of strings properties/functions or whatever--sort of vb6
style "inheritance"

NOt pretty but possible.

Shane
 
Back
Top