扩展方法的一个很好的用途是使语言更具功能性
Sub Main() Dim strings = { "One", "Two", "Three" } strings.Join(Environment.NewLine).Print() End Sub <Extension> Public Function Join(strings As IEnumerable(Of String), separator As String) As String Return String.Join(separator, strings) End Function <Extension> Public Sub Print(text As String) Console.WriteLine(text) End Sub