Pass data between managed and unmanaged code
Exchange primitives, structures, arrays, and strings between managed C# code and unmanaged native code.
読み終わるまでの所要時間 1 分最終更新 5日前
When you call functions across the boundary between managed C# code and unmanaged native code, both sides must agree on the memory layout of the data and how long it stays in memory. How you pass data depends on its type: primitive values, structs and unions, NativeArrays, and strings each need different handling.
Topic | Description |
|---|---|
| Pass data between managed and unmanaged code introduction | Understand how the stack, the managed heap, and marshalling affect data you pass to native code, and when to pin data in memory. |
| Match primitive types between C# and native code | Declare matching C# and C types so primitive values pass without data corruption. |
| Structures, classes, and unions | How to pass complex types. |
| NativeArrays | How to pass NativeArray objects. |
| Pass strings between C# and native code | How to pass string objects. |