0

Hi,

Thanks for DaniWeb for its contribution.

I was looking for a understandable example to the problem "How marshalling happens when it comes C# from C++ specially for structure", And i am glad that i got a nice example in this forum.

However, i am in problem when it comes to pointer to structure. Let me put some samples here;

Example:

struct Dept
{
   int dept_no;
   char name[24];
};

struct Emp
{
   int emp_no;
   int emp_name[24];
   struct Dept *stDept;
};

In above example, the problem line is "struct Dept *stDept;".

I would like to inform you that i am able to solve below pointer involvement:

Example: Working code

C++ : void* hThreadHandle;
C# : public IntPtr hThreadHandle;

Example: Not working code

struct Dept *stDept;

Thanks in advance for reply.

2
Contributors
1
Reply
6
Views
2 Years
Discussion Span
Last Post by ddanbe
0

You can only work with pointers in C#, if you put the code in an unsafe block.
Plus, you must mark it also in the build tab of the properties window of your project.
Hope it helps.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.