Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

in vb.net, if i wanted to convert types, i could use directcast and return a value from say an object:

 

Dim AL As ArrayList

AL = DirectCast(BinaryFormatter.Deserialize(FileStream), ArrayList)

 

and it could convert it to an arraylist, im trying to do the same in C++, but apparently C++ doesnt have the directcast function, and its not under the convert functions (::System::Convert::???)

any help appreciated, thx in advance

  • Leaders
Posted

I think a dynamic cast would be the closest to a DirectCast. C-style casts are considered bad practice by many--it is very flexible, but as a result sometimes what exactly it will do is hard to predict. A dynamic cast is the only non-C-style cast that will perform type checking (like any .Net cast).

 

someType someVarialbe = dynamic_cast<someType> (anotherVariable);

[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...