zoukankan      html  css  js  c++  java
  • C#内存复制与比较

    比较:

     public static extern int comp2(byte[] a, byte[] b, int count);
            [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl, SetLastError = false)]
            static extern int memcmp(byte[] b1, byte[] b2, UIntPtr count);
            [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl, SetLastError = false)]
            static extern int memcmp(IntPtr ptr1, IntPtr ptr2, int count);
            [DllImport("msvcrt.dll",  CallingConvention = CallingConvention.Cdecl, SetLastError = false)]
            static extern unsafe int memcmp(void* ptr1, void* ptr2, int count);

    复制:

       [DllImport("msvcrt.dll", EntryPoint = "memcpy", CallingConvention = CallingConvention.Cdecl, SetLastError = false)]
            public static extern IntPtr memcpy(IntPtr dest, IntPtr src, UIntPtr count);
            [DllImport("msvcrt.dll", EntryPoint = "memcpy", CallingConvention = CallingConvention.Cdecl, SetLastError = false)]
            public static extern IntPtr MemCopy(byte[] dest, byte[] src, UIntPtr count);
     

    还有一个复制的方法:

     System.Runtime.InteropServices.Marshal.Copy(buffer, bytes, 0, size)
     

  • 相关阅读:
    并发编程-操作系统简史,多道技术
    python下的excel表格处理 内含面试题
    epoll模型的探索与实践
    nginx搭建静态网站
    面向对象基础
    python+Django 下JWT的使用
    linux的history命令
    携程apollo配置中心Quick Start
    redis哨兵
    redis的主从复制
  • 原文地址:https://www.cnblogs.com/81/p/2289025.html
Copyright © 2011-2022 走看看