1
static
void
Main(
string
[] args)
2 {
3 string str = " Hello world " ;
4 IntPtr bstr = Marshal.StringToBSTR(str);
5 IntPtr p = bstr;
6 char * c;
7 while (p != (IntPtr)(( long )bstr + sizeof ( char ) * str.Length))
8 {
9 c = ( char * )p;
10 Console.WriteLine( * c);
11 p = (IntPtr)(( long )p + sizeof ( char ));
12 }
13 Marshal.FreeBSTR(bstr);
14 }
2 {
3 string str = " Hello world " ;
4 IntPtr bstr = Marshal.StringToBSTR(str);
5 IntPtr p = bstr;
6 char * c;
7 while (p != (IntPtr)(( long )bstr + sizeof ( char ) * str.Length))
8 {
9 c = ( char * )p;
10 Console.WriteLine( * c);
11 p = (IntPtr)(( long )p + sizeof ( char ));
12 }
13 Marshal.FreeBSTR(bstr);
14 }