Sign in to follow this  
couetcouet

Unity [.net] Managed, Unmanaged : Use and Convert String [] in char * []

Recommended Posts

couetcouet    122
Hello, I am working on a c# application which use managed dll based on unmanaged code. In the c# I have : String[] arraystring In the managed code : ???????????? In the unmanaged c++ function I have char* arraychar [] My problem is I don't know what type I need to use in my Managed c++ function. What is the type of the parameter : System::String^[] (with [] it doesn't works) ? How I convert the parameter in char *[] ? I found this post maybe useful: http://www.gamedev.net/community/forums/topic.asp?topic_id=290530

Share this post


Link to post
Share on other sites
Mike.Popoloski    3258
If you are writing a C++/CLI wrapper for your unmanaged function, you can do something like this:


array<String^> ManagedFunction()
{
array<String^>^ results = gcnew array<String^>( count );

for( int i = 0; i < count; i++ )
results[i] = gcnew String( unmanagedStringArray[i] );

return results;
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this