代码之家  ›  专栏  ›  技术社区  ›  Simsons

编组是否仅用于将结构转换为字节和反之亦然?

  •  1
  • Simsons  · 技术社区  · 14 年前

    Marshall 代码片段的想法是,封送处理用于将结构转换为字节和其他一些类似的转换。但这是马歇尔唯一的用途吗?

    在查看MSDn样本时,我得到了一条底线:

     // Initialize unmanged memory to hold the struct.
      IntPtr pnt = Marshal.AllocHGlobal(Marshal.SizeOf(p));
    

    When you work with `unmanaged` code, you are `marshaling` data from your
    `managed app-domain` to the `unmanaged` realm.
    

    Manged UnManaged 域或 managed unmanaged 代码。在编写代码时,我将如何区分 Managed 那是什么 非受管的 ?


    苏汶

    2 回复  |  直到 14 年前
        1
  •  1
  •   Warty    14 年前


    非托管代码是运行时不依赖CLR的代码,例如C程序。

        2
  •  0
  •   GarethOwen    14 年前

    托管=.NET(CLR公共语言运行时)

    非托管=本机

    使用“混合模式”程序集,以C++和CLR编程,将两个领域连接在一起。