0

I am tring to create byte array and I used below line of code.

1. let mutable buffer = Array.zeroCreate<byte> //Showing type (int->byte[])
2. let buffer =Array.create<byte> 32768 0uy //showing type (byte[])

Please let me know which way is more suitable for specific situation and when what is different between this 2 line of code

chirag
  • 1,818
  • 1
  • 15
  • 36
  • In create you can specify the value, to be non-zero if you want – John Palmer Jul 22 '15 at 10:28
  • I have specified the value "0uy " in create. – chirag Jul 22 '15 at 10:30
  • So the end result is the same then – John Palmer Jul 22 '15 at 10:31
  • In first line of code, if i am trying assign byte array then is show error "The type '(int -> byte [])' does not support the 'equality' constraint because it is a function type" – chirag Jul 22 '15 at 10:33
  • `int->byte[]` is telling you it's a function. You forgot to pass in the size of the array. BTW this is not related to the question linked as duplicate. @JohnPalmer undo this please. – Mauricio Scheffer Jul 22 '15 at 11:03
  • Also note that even though you want to mutate the individual entries in the array, you do not need to mark `buffer` as mutable. – torbonde Jul 22 '15 at 11:12
  • I think it is a duplicate - I would post exactly the same answer. I view the mistake in the mutable line as a typo given the title. – John Palmer Jul 22 '15 at 11:12
  • @JohnPalmer -I think that question and given answer both are different. I am asking about which statement used when more powerful way of coding. – chirag Jul 22 '15 at 17:30

0 Answers0