# How do I convert an array pointer returned by a native library into a class in C#

**URL:** <https://discuss.kotlinlang.org/t/how-do-i-convert-an-array-pointer-returned-by-a-native-library-into-a-class-in-c/28979>\
**Category:** Native\
**Created:** [July 29, 2024, 11:43pm UTC](https://discuss.kotlinlang.org/t/how-do-i-convert-an-array-pointer-returned-by-a-native-library-into-a-class-in-c/28979 "2024-07-29T23:43:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![BKT](https://avatars.discourse-cdn.com/v4/letter/b/7cd45c/32.png) [@BKT](https://discuss.kotlinlang.org/u/BKT)\
**Post date:** [July 29, 2024, 11:43pm UTC](https://discuss.kotlinlang.org/t/how-do-i-convert-an-array-pointer-returned-by-a-native-library-into-a-class-in-c/28979/1 "2024-07-29T23:43:17Z")

</div>

Given this delegate:  
`public delegate* unmanaged[Cdecl]<lib_kref_Resource, lib_kref_kotlin_Array> listUsers;`

With the next struct definition (generated with ClangSharpPInvokeGenerator):

```auto
typedef struct {
  lib_KNativePtr pinned;
} lib_kref_kotlin_Array;

public unsafe partial struct lib_kref_Resource
{
    public void* pinned;
}

```

And knowing that the kotlin code is like this:

```auto
class Resource {

    class User(
        val id: String,
        val name: String,
        val email: String
    )
    
    fun getUsers(): Array<User> {
        return arrayOf(User("user-id", "user-name", "user-email"))
    }
}

```

How can I convert the pointer? returned by the `listUser` function into a `User[]` array in **C#**?
