In types other than instance, I mean types that do not expose a public constructor due to the lack of a better term.
I want to extend the BitConverter class with overload ToString(), which takes a type parameter Charthat represents a value separator.
Why? By default, the call ToString()returns a string representation of the byte array, limited to barcode characters. The signature does not allow us to specify another separator, which I consider very unsuccessful.
Now, since this is not an instance type, but maybe because I overload the general method, it is difficult for me to find the correct syntax to define my extension method.
What I'm doing wrong here, resulting in overloads not appearing in IntelliSense:
Imports System.Runtime.CompilerServices
Module BitConverterExtensions
<Extension()>
Public Function ToString(ByVal converter As BitConverter, ByVal value() As Byte, ByVal delimiter As Char) As String
Return BitConverterExtensions.ToString(converter, value, 0, value.Length, delimiter)
End Function
<Extension()>
Public Function ToString(ByVal converter As BitConverter, ByVal value() As Byte, ByVal startIndex As Integer, ByVal delimiter As Char) As String
Return BitConverterExtensions.ToString(converter, value, startIndex, value.Length, delimiter)
End Function
<Extension()>
Public Function ToString(ByVal converter As BitConverter, ByVal value() As Byte, ByVal startIndex As Integer, ByVal length As Integer, ByVal delimiter As Char) As String
Dim bytes As String = BitConverter.ToString(value, startIndex, length)
Return bytes.Replace("-"c, delimiter)
End Function
End Module
Or is it simply impossible to extend general methods?