Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6160785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:21:50+00:00 2026-05-23T21:21:50+00:00

Earlier I asked if using as in C# was safe (i.e. won’t blow up):

  • 0

Earlier I asked if using as in C# was safe (i.e. won’t blow up): Is using "as" in C# a safe way of casting?

I liked the answer and ended up using something based off of it:

Foo x = y as Foo;
if (x != null)
{
    ...
}

But now I am converting my C# code to C++/CLI (due to a dependance issue..) so questions is..

I’m looking for the C++/CLI equivalent to “as”, that is safe and won’t blow up at runtime if not correct type. Can anyone suggest a cast that meets my needs? (please provide an example if you can)

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T21:21:51+00:00Added an answer on May 23, 2026 at 9:21 pm

    The C++ way to do such a thing is dynamic_cast. I don’t know if it’s the same for managed references as unmanaged references, MSDN had very little information on it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Despite an earlier question ( asked here ), our project is constrained to using
A related question to one I asked earlier ... Just checking on something: Should
Earlier I asked this question ( and after some googling I read Using your
I know I asked a related question earlier. I just had another thought. using
My question relates to this question asked earlier. In situations where I am using
Earlier, I asked this question: How can I perform a ping or traceroute using
I asked a simialr question earlier about using jquery and hashtags but what I
I asked a question earlier today regarding using Perl to search in a CSS
I asked a question earlier on defining a structure using malloc. This was the
So I asked a question with the same title earlier and got an answer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.