It's a good question, and I can give you a partial answer.
First, you must understand that strings are very special in .NET. The
functionality you describe works by calling special IL instructions, in this
case ldstr (load string). All assignment operators are that have a left hand
side string variable will use ldstr. There's no real way for you to do the
exact same thing.
As shown here:
http://blog.dreamprojections.com/arc...04/05/768.aspx
you can overload the implicit operator back to the underying type to achieve
something somewhat like the same behaviour, but the underlyign
implementation is quite different.
Karl
--
http://www.openmymind.net/
"Saran" <sx*****@qwest.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
Hi all,
Sorry if my question looks weird. But i still want to
understand. Let's see the below code
Dim myStr as string = "Hello"
Msgbox(myStr) ' Would display hello
I am wondering about the behaviour of the string as an object.
How comes it can receive and produce values without accessing any of
its properties. In other words, How to create a class that could behave
exactly like how String behaves.
i.e., For example, if i create a class called "MyOwnString"
What should i do so that below code can work
Dim myStr as MyOwnString = "Hello" ' Should get assgined
Msgbox(myStr) ' Should
display assigned value
Thanks,
Saran.