ExtensionMethod.NET Home of 840 C#, Visual Basic, F# and Javascript extension methods


Provides Self method for all classes. This is useful inside a With block (when you don't want to declare a variable which references the object you are working with) as it allows you to assign the newly instantiated object. Use this when instantiating objects to which you need a moment's reference.


<Runtime.CompilerServices.Extension()> _
Function Self(Of T)(ByVal x As T) As T
    Return x
End Function


With MyDataSet.Tables("SuperUsers")
  With .NewRow() 
    .Item("FirstName") = "Mario"
    .Item("LastName") = "Lanza"
    .Item("SecurityLevel") = 10
  End With
End With

Author: Mario T. Lanza

Submitted on: 28 jan 2009

Language: VB

Type: System.Object

Views: 3604