Conditional Compilation in VB.NET

This article demonstrates how to write conditional statements in Visual Basic .NET that will compile code based on given conditions
  • 1869

This article demonstrates how to write conditional statements in Visual Basic .NET that will compile code based on given conditions.

Here is a code sample that compiles code based on the values of Const defined above.

#Const Today = True
#Const Tomorrow = False
Class C
#If Today Then
    Sub F()
    End Sub
#Else
    Sub G()
    End Sub
#End If
#If Tomorrow Then
    Sub H()
    End Sub
#Else
    Sub I()
    End Sub
#End If
End Class

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.