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

  • SEARCH
  • Home
  • 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 9244927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:08:58+00:00 2026-06-18T09:08:58+00:00

What is the best online guide/tutorial to start with interop using C# and C++/CLI

  • 0

What is the best online guide/tutorial to start with interop using C# and C++/CLI ? I’m looking for a good guide in passing structures made in C# to C++/CLI. Many of the tutorials I have seen do not cover passing custom structures made in C# to C++/CLI.
Any suggestions ?

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-06-18T09:08:59+00:00Added an answer on June 18, 2026 at 9:08 am

    The reason you don’t find many tutorials is that there is really nothing to it. You pass the managed structure from C# to C++/CLI the same way as you would to another C# class/method

    say you had structure in C#:

    public struct TheStruct
    {
      public int i;
      public String str;
    }
    

    You would write a method in C++/CLI that looked like this:

    // *.h
    void PassStruct(TheStruct ^myStruct); 
    
    
    // *.cpp
    void classnamegoeshere::PassStruct(TheStruct ^myStruct)
    {
       int j = myStrict->i;
       String ^localStr = myStruct->str;
    }
    

    So, a couple of notes…

    1. you need to make sure you put the using statement in your C++/CLI
      code to get your C# reference
    2. Include the C# assembly (that defines the struct) in the C++/CLI reference list)
    3. Managed objects always use the ^ pointer notation (vs. *)
    4. To use methods or member use standard pointer notation ( -> )
    5. You need to be careful not to create circular references, so you may want to have TheStruct defined in C++/CLI in which case it would
      look like:

      public ref struct TheStruct
      {
      public:
      int i;
      String ^str;
      }

    Easy enought?

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

Sidebar

Related Questions

Possible Duplicates: script to tell me who, and how many users, are online Best
I was looking around for the best method to do an online backup of
Does anyone have recommendations on the best Online Store for non-technical users of Joomla?
what is the best suited programming language and technologies to make an online chatting
I'm working on creating an online guide. It will survey users, and based on
What's the best online resource to learn about installing JSON API's
Been searching online for best ways to embed interactive spreadsheets into my website. My
I'm creating a web-based online game and am trying to find the best fit
I'm a front-end developer and I was looking for opinions about the best all-round
Best Online Open source Project manager/Task Manager???

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.