日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
C#操作內(nèi)存讀寫方法淺析

C#操作內(nèi)存讀寫方法是什么呢?讓我們來(lái)看看具體的實(shí)例實(shí)現(xiàn):

伊美網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián),伊美網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為伊美上千家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站制作要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的伊美做網(wǎng)站的公司定做!

 
 
 
  1. using System.Runtime.InteropServices;  
  2. using System.Text;  
  3. public class Function  
  4. {  
  5.  //C#操作內(nèi)存讀寫方法
  6. public static byte PtrToByte( int Ptr )  
  7. {  
  8. byte b = Marshal.ReadByte( ( IntPtr ) Ptr );  
  9.  
  10. return b;  
  11. }  
  12.  
  13. public static char PtrToChar( int Ptr )  
  14. {  
  15. byte b = Marshal.ReadByte( ( IntPtr ) Ptr );  
  16.  
  17. return ( char ) b;  
  18. }  
  19.  
  20. public static short PtrToShort( int Ptr )  
  21. {  
  22. short b = Marshal.ReadInt16( ( IntPtr ) Ptr );  
  23.  
  24. return b;  
  25. }  
  26.  //C#操作內(nèi)存讀寫方法
  27. public static ushort PtrToUShort( int Ptr )  
  28. {  
  29. ushort b = ( ushort ) Marshal.ReadInt16( ( IntPtr ) Ptr );  
  30.  
  31. return b;  
  32. }  
  33.  
  34. public static int PtrToInt( int Ptr )  
  35. {  
  36. int b = Marshal.ReadInt32( ( IntPtr ) Ptr );  
  37.  
  38. return b;  
  39. }  
  40.  
  41. public static uint PtrToUInt( int Ptr )  
  42. {  
  43. uint b = ( uint ) Marshal.ReadInt32( ( IntPtr ) Ptr );  
  44.  
  45. return b;  
  46. }  
  47.  
  48. public static long PtrToLong( int Ptr )  
  49. {  
  50. long b = Marshal.ReadInt64( ( IntPtr ) Ptr );  
  51.  
  52. return b;  
  53. }  //C#操作內(nèi)存讀寫方法
  54.  
  55. public static ulong PtrToULong( int Ptr )  
  56. {  
  57. ulong b = ( ulong ) Marshal.ReadInt64( ( IntPtr ) Ptr );  
  58.  
  59. return b;  
  60. }  
  61.  
  62.  
  63. // Convert an ip address stored an address to equivalent string value  
  64. public static string GetPtrToIpAddr(int intPtr, int varlen)  
  65. {  
  66. int i = 0;  
  67. StringBuilder sb = new StringBuilder(0,varlen*4);  
  68. byte[] byx = new byte[varlen];  
  69.  
  70. // ip address cann't have zero value C#操作內(nèi)存讀寫方法  
  71. // ip address cann't have zero length C#操作內(nèi)存讀寫方法
  72. if( ( intPtr == 0 ) || ( varlen == 0 ) ) return "";  
  73. Marshal.Copy( ( IntPtr ) intPtr , byx , 0 , varlen );  
  74. for( i = 0; i < varlen - 1; i ++ )  
  75. {  
  76. sb.Append(byx[i]);  
  77. sb.Append('.');  
  78.  
  79. }  
  80. sb.Append(byx[varlen - 1]);  
  81.  
  82. return sb.ToString();  
  83.  
  84. }  
  85.  

C#操作內(nèi)存讀寫方法的基本內(nèi)容就向你介紹到這里,希望對(duì)你了解和學(xué)習(xí)C#操作內(nèi)存讀寫方法有所幫助。


當(dāng)前題目:C#操作內(nèi)存讀寫方法淺析
標(biāo)題網(wǎng)址:http://www.5511xx.com/article/dpdgpeh.html