[转载]C#中int和IntPtr相互转换

方法一、

          int转IntPtr

           int i = 12;
           IntPtr p = new IntPtr(i);

           IntPtr转int

           int myi = (int)p;
           MessageBox.Show(myi.ToString());

 

方法二、

          int转IntPtr

           int i = 12;
           IntPtr p =(IntPtr)i

           IntPtr转int

           int myi = (int)p;
           MessageBox.Show(myi.ToString());

posted on 2014-04-15 01:17  iackjee  阅读(5847)  评论(0编辑  收藏  举报

导航