DefineLabel Method

ILGenerator.DefineLabel Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Declares a new label.

Namespace:  System.Reflection.Emit
Assembly:  mscorlib (in mscorlib.dll)

'Declaration
Public Overridable Function DefineLabel As Label

Return Value

Type: System.Reflection.Emit.Label
A new label that can be used as a token for branching.

The label is just a token and does not yet represent any particular location within the stream. To set the position of the label within the stream, you must call the MarkLabel method.

The following example demonstrates the use of the DefineLabel method to define three labels. This code is part of a larger example provided for the BeginExceptionBlock method.


' Define labels for branching. The labels can be used immediately in Emit
' calls, but they do not acquire their target locations until the 
' MarkLabel(Label) method is called at the location in the program that
' the label applies to.
'
Dim succeeded As Label = adderIL.DefineLabel()
Dim skipOutputInFinally As Label = adderIL.DefineLabel()
Dim skipOutputInCatch As Label = adderIL.DefineLabel()


Windows Phone OS

Supported in: 8.1, 8.0, 7.1

Windows Phone

Show:
© 2017 Microsoft