首页  编辑  

放问字符串的内存

Tags: /C#/其他技巧/   Date Created:

string S = "Zswang ;

IntPtr P = Marshal . StringToBSTR(S);

int count = 0 ;

while ( Marshal . ReadInt16(P) != 0 )

{

   P = new IntPtr ((int)P + 2 );

   count ++ ;

}

Text = count . ToString();