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 6144923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:43:13+00:00 2026-05-23T18:43:13+00:00

I had read that the C++/CLI ref class was the equivalent to a C#

  • 0

I had read that the C++/CLI ref class was the equivalent to a C# class. However, I’m seeing a difference between this in each class.

EDIT: I obtained this from Visual Studio 2010’s locals. (Also, I noted a difference at compile time when doing exact same cast – the C++/CLI class gave an error stating it could not convert Object^ to MyClass^, whereas casting with the C# class creates no errors at compile time).

C# class:

namespace MyNamespace
{

   public class MyClass
   {    
       public MyClass()
           {
               //Do something
           }
   }
}

this = MyNamespace.MyClass (What I expect and want!)


C++/CLI ref class:

namespace MyNamespace
{

   public ref class MyClass
   {    
       public:
           MyClass::MyClass()
           {
               //Do something
           }
   }
}

this = System::Object^ (Not what I expected or want!!)


I would expect this to be like the C# example, which states that this is of type MyClass. However, the C++/CLI ref class states it is of type Object.. Which is definitely NOT what I want.
(This makes it difficult in various situations, such as casting in a C++ function).

So my question is (two part):

a) why are these classes behaving differently with this?

b) how do I get my C++/CLI ref class to have the correct type in this??

Thanks for your time in advance!

  • 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-23T18:43:14+00:00Added an answer on May 23, 2026 at 6:43 pm

    What you are seeing in the debugger is the name of the base class – in this case Object^. Change the base class of MyClass to something else and you will see what I mean.

    Locals window

    Note that the right most column displays the type.

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

Sidebar

Related Questions

I had read in some design book that immutable class improves scalability and its
I read that this exception means that I added a LinearLayout that had no
I had read somewhere about one specific feature that is present in awk but
I was fairly sure that I had read (in Richter's C# book) that objects
I've read somewhere that the trunk version of Firefox already had a WebSocket implementation.
I recently read in a presentation on Scribd that Facebook had benchmarked a variety
I read that hash tables in Haskell had performance issues (on the Haskell-Cafe in
I've read that in older versions of SQL Server .. it had a pessimistic
Long time back in past I had read somewhere that if we want to
I had read in another post here on SO that when possible you shouldn't

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.