How I can resolve the problem?
Well, you simply can't using Encoding.Default
as a default parameter value.
What you could do is use Nothing
as a default parameter value, and simply have:
If Encoding Is Nothing Then
Encoding = System.Text.Encoding.Default
End If
This does mean you can't use Nothing
for a different meaning, mind you.
Another alternative would be to just use overloading - provide one version without the encoding parameter which just called the version with the encoding parameter, passing in Encoding.Default
.
Two other points to note:
- Your parameter names don't follow .NET naming conventions; they should be camelCased
Encoding.Default
is generally a bad default to use (and poorly named). Pretty much everything in .NET actually usesEncoding.UTF8
as the default encoding if you don't specify one; I'd urge you to follow suit.