# What am I able to cast to ^Void?

**URL:** https://talk.remobjects.com/t/what-am-i-able-to-cast-to-void/12567
**Category:** Oxygene
**Tags:** visual-studio, oxygene
**Created:** [March 28, 2017, 2:36pm UTC](https://talk.remobjects.com/t/what-am-i-able-to-cast-to-void/12567 "2017-03-28T14:36:36Z")
**Posts on this page:** 6
**Page:** 2

<div class="post-metadata">

### Author: ![shpend\_hoti](https://talk.remobjects.com/user_avatar/talk.remobjects.com/shpend_hoti/32/18171_2.png) [@shpend\_hoti](https://talk.remobjects.com/u/shpend_hoti)
#### Post date: [March 29, 2017, 3:21pm UTC](https://talk.remobjects.com/t/what-am-i-able-to-cast-to-void/12567/21 "2017-03-29T15:21:25Z")

</div>

> [@shpend\_hoti](#):
>
> sizeOf(data) \* 1);

But i even tried to write just a single string(text) in the memstream and it still does work, there im not longer in known addresssapce? 😮

```
var str := 'jdsghdfjhdujfdhf';
  
  d.Write(@str, sizeOf(str) * 1);

  d.Position := 0;

  var res : String;

  d.Read(@res, sizeOf(String)* 1);

  writeLn(res);

```

---

<div class="post-metadata">

### Author: ![shpend\_hoti](https://talk.remobjects.com/user_avatar/talk.remobjects.com/shpend_hoti/32/18171_2.png) [@shpend\_hoti](https://talk.remobjects.com/u/shpend_hoti)
#### Post date: [March 29, 2017, 4:14pm UTC](https://talk.remobjects.com/t/what-am-i-able-to-cast-to-void/12567/22 "2017-03-29T16:14:27Z")

</div>

Is it able that you can fix this with generic T?

Meaning, that the memorystream is able to accept an: @generic\_variable ?

---

<div class="post-metadata">

### Author: ![ck](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ck/32/8740_2.png) [@ck](https://talk.remobjects.com/u/ck)
#### Post date: [March 29, 2017, 4:40pm UTC](https://talk.remobjects.com/t/what-am-i-able-to-cast-to-void/12567/23 "2017-03-29T16:40:32Z")

</div>

Afaik that already works. Howver pair.item1 is a property. You can’t take the address of a property, you’d have to use a local. But once again, this is not going to work with any reference type. Ie strings classes, dynamic arrays

---

<div class="post-metadata">

### Author: ![shpend\_hoti](https://talk.remobjects.com/user_avatar/talk.remobjects.com/shpend_hoti/32/18171_2.png) [@shpend\_hoti](https://talk.remobjects.com/u/shpend_hoti)
#### Post date: [March 29, 2017, 5:34pm UTC](https://talk.remobjects.com/t/what-am-i-able-to-cast-to-void/12567/24 "2017-03-29T17:34:24Z")

</div>

Unfortunately, it doesnt work, when i do it with generics:

i removed the tuple and wrote the Parameter directly and it still doesnt work, i get an error like that\_

"Error (E406) No overloaded method “Write” with these parameters on type “MemoryStream”, best matching overload is “method Write(buf: ^Void; Count: Int32): Int32”

method TSample.Write(const bla: T);  
begin  
f\_buffer.Write(@bla, sizeof(bla) \* 1); // the error above  
end;

---

<div class="post-metadata">

### Author: ![ck](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ck/32/8740_2.png) [@ck](https://talk.remobjects.com/u/ck)
#### Post date: [March 30, 2017, 4:48am UTC](https://talk.remobjects.com/t/what-am-i-able-to-cast-to-void/12567/25 "2017-03-30T04:48:33Z")

</div>

Drop the “const”. you’re taking the address of something, which means it has to be writable.

---

<div class="post-metadata">

### Author: ![shpend\_hoti](https://talk.remobjects.com/user_avatar/talk.remobjects.com/shpend_hoti/32/18171_2.png) [@shpend\_hoti](https://talk.remobjects.com/u/shpend_hoti)
#### Post date: [March 30, 2017, 7:26am UTC](https://talk.remobjects.com/t/what-am-i-able-to-cast-to-void/12567/26 "2017-03-30T07:26:33Z")

</div>

Thanks!! 🙂

Did oversee this totally… ofc you are right ^^

[Previous page](https://talk.remobjects.com/t/what-am-i-able-to-cast-to-void/12567.md?page=1)
