# How can I use GetBufferAsInt64 in c#

**URL:** https://discourse.itk.org/t/how-can-i-use-getbufferasint64-in-c/3623
**Category:** Beginner Questions
**Created:** [November 15, 2020, 9:41pm UTC](https://discourse.itk.org/t/how-can-i-use-getbufferasint64-in-c/3623 "2020-11-15T21:41:30Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Anders\_G](https://discourse.itk.org/user_avatar/discourse.itk.org/anders_g/32/1792_2.png) [@Anders\_G](https://discourse.itk.org/u/Anders_G)
#### Post date: [November 15, 2020, 9:41pm UTC](https://discourse.itk.org/t/how-can-i-use-getbufferasint64-in-c/3623/1 "2020-11-15T21:41:30Z")

</div>

I want to access the raw data pointer of an image in simpleITK c#. (It will be sent to another native library.) I understand how to do it for types like sitkFloat32 and sitkInt32 since the GetBufferAsXXX returns a IntPtr that I can use. But for some types like Int64 I get a SWIGTYPE\_p\_long\_long instead. How can I use this object? Is it possible to cast it somehow to an adress that I can use?

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [November 16, 2020, 12:09pm UTC](https://discourse.itk.org/t/how-can-i-use-getbufferasint64-in-c/3623/2 "2020-11-16T12:09:43Z")

</div>

> [@Anders\_G](#):
>
> But for some types like Int64 I get a SWIGTYPE\_p\_long\_long instead. How can I use this object? Is it p

It looks like those interfaces need a little more refinement and testing. Are you able to use the return from `GetBufferAsVoid`?

---

<div class="post-metadata">

### Author: ![Anders\_G](https://discourse.itk.org/user_avatar/discourse.itk.org/anders_g/32/1792_2.png) [@Anders\_G](https://discourse.itk.org/u/Anders_G)
#### Post date: [November 17, 2020, 9:19am UTC](https://discourse.itk.org/t/how-can-i-use-getbufferasint64-in-c/3623/3 "2020-11-17T09:19:39Z")

</div>

No the GetBufferAsVoid returns a SWIGTYPE\_p\_void so that doesn’t work.

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [November 17, 2020, 2:14pm UTC](https://discourse.itk.org/t/how-can-i-use-getbufferasint64-in-c/3623/4 "2020-11-17T14:14:06Z")

</div>

Thanks for giving that a try. This PR will address the issue:

> <https://github.com/SimpleITK/SimpleITK/pull/1260/files>

It should be merged into master shortly, where the nightly builds will publish the [latest binaries](https://simpleitk.readthedocs.io/en/master/gettingStarted.html#latest-binaries). Then it will be merged into the release branch for the 2.0.2 release.

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [November 19, 2020, 12:15pm UTC](https://discourse.itk.org/t/how-can-i-use-getbufferasint64-in-c/3623/5 "2020-11-19T12:15:14Z")

</div>

Hello,

Have you had the opportunity test these the “latest” build with the fixed return type? We will like to incorporate this change into version 2.0.2 and your feedback is important.

Thank you
