> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/xamarin/learn-more/type-converter.md).

# Type Conversion

Learn how to use Apryse type conversion for calling C functions from C# in Xamarin SDK. Manage types and binding types efficiently with PInvoke. Explore key concepts and conversion examples. The Aprys

Apryse type conversion allows you to call C functions directly from C#.

{% tabs %}
{% tab title="Android" %}

## Managed type and binding types

Apryse for Xamarin SDK takes advantage of PInvoke which allows calling C functions from C# directly. This applies to all core classes that are shared between Xamarin.Android and Xamarin.iOS. However, the `PDFViewCtrl` class and PDFViewCtrlTools library are direct Xamarin bindings from the source code. This article will walk you through how to deal with managed type and binding types.

Key concepts:

* All managed types are in `pdftron` namespace
* All binding types are in `pdftronprivate` namespace

A [`TypeConvertHelper`](https://sdk.apryse.com/api/xamarinandroid/pdfnet/api/pdftron.PDF.TypeConvertHelper.html) class is provided to convert between managed types and binding types. For example:

### PDFDoc

From `pdftronprivate.PDF.PDFDoc` to `pdftron.PDF.PDFDoc`:

{% code lineNumbers="true" %}

```csharp
var pdfDoc = TypeConvertHelper.ConvPdfDocToManaged(privatePdfDoc);
```

{% endcode %}

From `pdftron.PDF.PDFDoc` to `pdftronprivate.PDF.PDFDoc`:

{% code lineNumbers="true" %}

```csharp
var privatePdfDoc = TypeConvertHelper.ConvPDFDocToNative(pdfDoc);
```

{% endcode %}

### Annot

From `pdftronprivate.PDF.Annot` to `pdftron.PDF.Annot`:

{% code lineNumbers="true" %}

```csharp
var annot = TypeConvertHelper.ConvAnnotToManaged(privateAnnot);
```

{% endcode %}

From `pdftron.PDF.Annot` to `pdftronprivate.PDF.Annot`:

{% code lineNumbers="true" %}

```csharp
var privateAnnot = TypeConvertHelper.ConvAnnotToNative(annot);
```

{% endcode %}
{% endtab %}

{% tab title="iOS" %}

## Managed type and binding types

Apryse for Xamarin SDK takes advantage of PInvoke which allows calling C functions from C# directly. This applies to all core classes that are shared between Xamarin.Android and Xamarin.iOS. However, the `PDFViewCtrl` class and PDFViewCtrlTools library are direct Xamarin bindings from the source code. This article will walk you through how to deal with managed type and binding types.

Key concepts:

* All managed types are in `pdftron` namespace
* All binding types are in `pdftronprivate` namespace

A [`TypeConvertHelper`](https://sdk.apryse.com/api/xamarinios/pdfnet/api/pdftron.PDF.TypeConvertHelper.html) class is provided to convert between managed types and binding types. For example:

### PDFDoc

From `pdftronprivate.PTPDFDoc` to `pdftron.PDF.PDFDoc`:

{% code lineNumbers="true" %}

```csharp
var pdfDoc = TypeConvertHelper.ConvPdfDocToManaged(privatePdfDoc);
```

{% endcode %}

From `pdftron.PDF.PDFDoc` to `pdftronprivate.PTPDFDoc`:

{% code lineNumbers="true" %}

```csharp
var privatePdfDoc = TypeConvertHelper.ConvPDFDocToNative(pdfDoc);
```

{% endcode %}

### Annot

From `pdftronprivate.PTAnnot` to `pdftron.PDF.Annot`:

{% code lineNumbers="true" %}

```csharp
var annot = TypeConvertHelper.ConvAnnotToManaged(privateAnnot);
```

{% endcode %}

From `pdftron.PDF.Annot` to `pdftronprivate.PTAnnot`:

{% code lineNumbers="true" %}

```csharp
var privateAnnot = TypeConvertHelper.ConvAnnotToNative(annot);
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/xamarin/learn-more/type-converter.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
