PDA

Click to See Complete Forum and Search --> : need help abt structures


rajayashwanth
Mar 24th, 2006, 05:24 AM
hi all
In my c# application,I am using functions of VC++.Net.
One of the function in that VC++ dll is taking Char * as an argument.
But in My C# application I have one structure variable.
I want this structure variable to be passed to that VC++.Net dll's function.

This is in C#.Net

structure struct1
{
int i;
char[] arr;
};
Am writing the following code under Button_click event(in C#)

struct1 ss=new struct1()
ss.i=10;
ss.arr=new char[10];
ss.arr="abcde".ToChararray();
work(ss); ?? /***** this is the function in vc++.net ****??????????
Now I want to pass thi structure variable(struct1) to the VC++.Net function which is having char * as its argument.
The function in VC++.Net is like this..
char * work(char * C)
{
/// some code
}

So plzz tell me Can I pass the structure from C#.Net to that VC++.Net function which is taking Char *.
Thanks in advance.

wossname
Mar 24th, 2006, 12:33 PM
Look into "unsafe" code and pointers (C# does support pointers). MSDN has some good info about it.