Code in VB.NET
Module Utils <Runtime.CompilerServices.Extension()> _ Public Sub Print(ByVal message As String) Console.WriteLine(message) End Sub End Module Public Class Foo Public Sub New() Dim test = "cucu" test.Print() ' no problem: custom string extension method ' "cucu".Print() ' syntax error ' End Sub End Class
1) The first problem, I would prefer to use "cucu" .MyExtensionMethod (), as well as test.MyExtensionMethod ();
1 ') Syntax like
"No Result".Print() ' Print is an extension method ' " No Result ".Trim() ' Trim is a framework method '
both of them do not work
However, the syntax is kind of
myTextBox.Text = "No Result".Translate() ' Translate is an extension method ' myTextBox.Text = " No Result ".Trim() ' Trim is a framework method '
works very well.
So, there seems to be some consistency in the string behavior sequence.
2) Look at the COMMENTS (in the attached figure). The words "custom", "string" and "error" are highlighted, however they are in the comments, so they should be green, not blue.
Why is this? What is the workaround?
EDIT:
Declared as βerrorβ in Microsoft Connect (even if it is no more syntactic βmissβ) ...
EDIT 2:
As Hans Passant noted, standard string methods like "cucu".Trim() do not work either.
serhio
source share