Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Arrays and stuff

Arrays and stuff

Scheduled Pinned Locked Moved Managed C++/CLI
csharphelpquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    stephen woolhead
    wrote on last edited by
    #1

    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.

    N 1 Reply Last reply
    0
    • S stephen woolhead

      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.

      N Offline
      N Offline
      Nick Hodapp
      wrote on last edited by
      #2

      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.

      N 1 Reply Last reply
      0
      • N Nick Hodapp

        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.

        N Offline
        N Offline
        Nish Nishant
        wrote on last edited by
        #3

        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]

        J 1 Reply Last reply
        0
        • N Nish Nishant

          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]

          J Offline
          J Offline
          James T Johnson
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups