Safe casting in C++/CLI - equivalent to C#'s "as"?

Viewed 4634

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!

3 Answers
Related