doc,
Technically, you'd have to extend String. I'm not sure if base types
are declared partial in 2.0, but even if they are, that's probably a
bad idea.
You'd do much better to have a MyPropclass(string) constructor, or
maybe a static MyPropclass MyPropclass.Factory(string) method. If
MyPropclass encapsulates substantially more than a string, void
MyPropclass.Assimilate(string) may be appropriate. Alternately, if
you're into "clean" language constructs, you can write static
MyPropclass operator+(string, MyPropclass) and end up with:
MyPropclass prop = new MyPropclass();
[ ... do stuff with prop ... ]
string m = "mystring";
prop += m;
Does that help?
Stephan
docschnipp wrote:
Hi,
I have an object that manages a kind of Variant type. For comfort reasons I
want to have the possibility to do this:
MyPropclass prop = new MyPropclass();
string m = "blabla";
prop = m;
How can I do this? Is there a way to overwrite "="? Or must I extend "string"?
Thanks
doc