pradeepTP
Sat Jan 14 23:11:03 CST 2006
Hi all,
Mattias has given some interesting information. I will now find more about
tail and cpblk.
I thank you all for your help. I hope i get to hear more about this from
more experts. I also would like to express my special thanks to john skeet. I
have read many of his blogs and find it all very interesting. I feel honoured
to see your reply on this thread john :).
thanks
pradeep
"Mattias Sjögren" wrote:
> >Do any of the languages allow you to modify a boxed value in place?
>
> This works for me:
>
> // Old syntax
> __value struct Foo
> {
> public:
> Foo(int x) { this->x = x; }
> virtual String * ToString() { return __box(x)->ToString(); }
> int x;
> };
>
> int main()
> {
> Object *o = __box(Foo(42));
> dynamic_cast<Foo*>(o)->x = 123;
> Console::WriteLine(o);
> return 0;
> }
>
> // New syntax, compiles with /clr:safe
> value struct Foo
> {
> public:
> Foo(int x) { this->x = x; }
> virtual String^ ToString() override { return x.ToString(); }
> int x;
> };
>
> int main()
> {
> Object ^o = Foo(42);
> dynamic_cast<Foo^>(o)->x = 123;
> Console::WriteLine(o);
> return 0;
> }
>
>
> To add to the list of things you can't do in C#, VB or C++, I don't
> think any of them ever generates the tail. or cpblk IL instructions.
>
>
> Mattias
>
> --
> Mattias Sjögren [C# MVP] mattias @ mvps.org
>
http://www.msjogren.net/dotnet/ |
http://www.dotnetinterop.com
> Please reply only to the newsgroup.
>