通過Marshall
代碼片段後得到了編組用於將Struct轉換爲Bytes和其他幾個類似convesrion的想法。但這是馬歇爾的唯一用途嗎?編組僅用於將結構轉換爲Byte和ViceVersa嗎?
雖然通過MSDN樣品去給我的floowing行:
// Initialize unmanged memory to hold the struct.
IntPtr pnt = Marshal.AllocHGlobal(Marshal.SizeOf(p));
而且還從其他一些網站,我得到了follwing線,如:
When you work with `unmanaged` code, you are `marshaling` data from your
`managed app-domain` to the `unmanaged` realm.
現在什麼是Manged
和UnManaged
域或managed
和unmanaged
的代碼。在編寫我的代碼時如何才能區分什麼是Managed
和什麼是unmanaged
?
我只是需要清理我的基本面之前,任何建議,文檔或演練作爲我真誠的感激。
謝謝,
Subhen
在我的代碼片段(來自MSDN)它說 //初始化unmanged內存來容納結構。 IntPtr pnt = Marshal.AllocHGlobal(Marshal.SizeOf(p)); 這裏是initializng非託管內存IntPtr pnt,那麼這是否意味着IntPtr不依賴於CLR來運行 – Simsons 2010-07-27 08:58:46
IntPtr =整數指針結構。它是CLR的一部分,它的全名是'System.IntPtr'。 IntPtr是一個值類型,其中包含一個整數,它是環境操作系統的地址大小...好吧,我很羅嗦,對不起。 – Warty 2010-07-27 09:10:18