Convert c# bytes array function to

I am trying to convert this code

public static byte[] NewLine(this byte[] bytes, int feeds = 1)
      return bytes.AddBytes(((IEnumerable<byte>) new byte[feeds]).Select<byte, byte>((Func<byte, byte>) (x => (byte) 10)).ToArray<byte>());

online converters produce this

<System.Runtime.CompilerServices.Extension> _
    Public Function NewLine(ByVal bytes() As Byte, Optional ByVal feeds As Integer = 1) As Byte()
      Return bytes.AddBytes((DirectCast(New Byte(feeds - 1){}, IEnumerable(Of Byte))).Select(Of Byte, Byte)CType(Function(x) CByte(10), Func(Of Byte, Byte)).ToArray())
    End Function

which gives an error

Overload resolution failed because no accessible 'Select' accepts this number of type arguments.

Can anyone help me out?

Jon Skeet

It's not clear to me why specifying the type arguments fails, but that isn't needed anyway - and the location of CType looks to be broken. If you change the Select call to:

.Select(CType(Function(x) CByte(10), Func(Of Byte, Byte)))

then it compiles - but you can also get rid of CType entirely:

.Select(Function(x) CByte(10))

(That simplification works in the C# code too, where this:

.Select<byte, byte>((Func<byte, byte>) (x => (byte) 10))

can be simplified to:

.Select(x => (byte) 10)


See more on this question at Stackoverflow