How to access a char* in DLL using c#

I'm using c#2008 exporess.

I have a dll contain a function
int test(char* str); written by other C languge.

I try to read the string in the function but always get error and it seems to be unsafe.
Hence, how to get the string in the function above?
Thank you.
xuanspiderAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Chris-in-ClaphamConnect With a Mentor Commented:
Assuming you are using DLLImport or similar construction to access the DLL then you will need to pass a StringBuilder object into the method.
0
 
xuanspiderAuthor Commented:
I think I did not explain clearly. The Dll is not compiled by visio studio, is compiled by other C language "labwindow". It only supports char*, but when I using char[] to read the function. C# does not allowed me to do so no matter I use ref or out keyword.  Is there any solution?
0
 
xuanspiderAuthor Commented:
Solve already. I never notice that char in vs2008 is 2 byte. Thank you.
0
 
Chris-in-ClaphamCommented:
Do you have a code example to show what you have tried? A short piece of code and the associated error message will make it a lot clearer as to exactly what you are trying to achieve.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.