C# code
byte[] array = bytes.Take<byte>(num).ToArray<byte>();
VB.NET Converted Code (i tried multiable ones. same result)
Dim array As Byte() = bytes.Take(Of Byte)(num).ToArray(Of Byte)()
got an error on : (of Byte)
Error
Extension method 'Public Function Take(count As Integer) As System.Collections.Generic.IEnumerable(Of TSource)' defined in 'System.Linq.Enumerable' is not generic (or has no free type parameters) and so cannot have type arguments
I don't have much experience with this, but it looks like if the VB compiler is able to infer the type arguments, it doesn't let you specify them explicitly. Assuming bytes
is a Byte
array (or an IEnumerable(Of Byte)
), you should be able to use:
Dim array As Byte() = bytes.Take(num).ToArray()
Frankly it's a little odd to redundantly specify the type arguments in C#, too - I'd normally write:
byte[] array = bytes.Take(num).ToArray();
See more on this question at Stackoverflow