Welcome to MSDN Blogs Sign in | Join | Help

Conversion between System.String and char *

We can convert a char * to System.String with System.String’s constructor

string str = new string((char*)p);

And for the reverse:

fixed(char *p = str){}

Why do we care about conversion between System.String and char *?

From this article, this is the fastest way to marshal strings between managed and native boundary.

Published Monday, August 11, 2008 8:00 AM by junfeng
Filed under:

Comments

# Conversion between System.String and char * | Easycoded

Monday, August 11, 2008 11:22 AM by Conversion between System.String and char * | Easycoded

# re: Conversion between System.String and char *

Tuesday, August 12, 2008 4:14 PM by Brian

That is a managed char*, so it's unicode. What would that be useful for?

Hardly a surprise that this would work ...

# re: Conversion between System.String and char *

Monday, October 13, 2008 3:01 PM by Artem Razin

Sorry for the bothering you. It seems that you're guru of SxS, and I have one interesting question regarding SxS. May I write you a question somehow?... How can I contact you?

Thank you in advance!

New Comments to this post are disabled
 
Page view tracker