Arrays and stuff
-
Could someone please tell me how I would do the following cast/conversion properly? It's late and my brain no longer functions.....
Object* oFields[] = new Object* [iFields]; oFields[i] = **(Object __gc* )**DateTime::Parse (sData.c_str ()) ;
the compiler currently tells me error C2440: 'type cast' : cannot convert from 'System::DateTime' to 'System::Object __gc *' give me c# any day :-) Thanks Stephen. -
Could someone please tell me how I would do the following cast/conversion properly? It's late and my brain no longer functions.....
Object* oFields[] = new Object* [iFields]; oFields[i] = **(Object __gc* )**DateTime::Parse (sData.c_str ()) ;
the compiler currently tells me error C2440: 'type cast' : cannot convert from 'System::DateTime' to 'System::Object __gc *' give me c# any day :-) Thanks Stephen.Stephen - DateTime is a value-type; it needs to be boxed first before it can be held in an Object array:
oFields[i] = __box(DateTime::Parse(sData.c_str()));
In C# boxing is done for you by the compiler (implicit boxing). In C++, because of the performance overhead associated with boxing, boxing is an explicit operation. Give ME the full power of C++ any day :) Nick This posting is provided “AS IS” with no warranties, and confers no rights. You assume all risk for your use. © 2001 Microsoft Corporation. All rights reserved.
-
Stephen - DateTime is a value-type; it needs to be boxed first before it can be held in an Object array:
oFields[i] = __box(DateTime::Parse(sData.c_str()));
In C# boxing is done for you by the compiler (implicit boxing). In C++, because of the performance overhead associated with boxing, boxing is an explicit operation. Give ME the full power of C++ any day :) Nick This posting is provided “AS IS” with no warranties, and confers no rights. You assume all risk for your use. © 2001 Microsoft Corporation. All rights reserved.
Nick Hodapp (MSFT) wrote: Give ME the full power of C++ any day Cool! Maybe I'll quote you in my next MC++ article. Last time I quoted you, you had used a newly invented word - "performant" - but this time your language was more conservative :-) Nish :-D
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]
-
Nick Hodapp (MSFT) wrote: Give ME the full power of C++ any day Cool! Maybe I'll quote you in my next MC++ article. Last time I quoted you, you had used a newly invented word - "performant" - but this time your language was more conservative :-) Nish :-D
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]
Nishant S wrote: Last time I quoted you, you had used a newly invented word - "performant" I don't think he invented the word; its one of those American words that just isn't in the dictionary :) Blasted dictionaries can't always be right ;P James "And we are all men; apart from the females." - Colin Davies