VB.Net Tutorial/Development/Pre Compile — различия между версиями

Материал из VB Эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Версия 16:40, 26 мая 2010

#Const

public class Test
   public Shared Sub Main
        #If UseFastAlgorithm Then
            Console.WriteLine("Fast")
        #Else
            Console.WriteLine("Slow")
        #End If
        
        #Const UseFastAlgorithm = True
        
        #If UseFastAlgorithm Then
           Console.WriteLine("Fast")
        #Else
           Console.WriteLine("Slow")
        #End If
   End Sub
End class
Slow
Fast

#ElseIf

public class Test
   public Shared Sub Main
#If CONFIG = "Debug" Then
        Console.WriteLine("Debug")
#ElseIf CONFIG = "Release" Then
        Console.WriteLine("Release")
#ElseIf CONFIG = "InterimBuild" Then
        Console.WriteLine("InterimBuild")
#Else
        Console.WriteLine("Unknown build type")
#End If
   End Sub
End class
Very Good.

#if, #Else, #End If

public class Test
   public Shared Sub Main
        #If UseFastAlgorithm Then
            Console.WriteLine("Fast")
        #Else
            Console.WriteLine("Slow")
        #End If
        
        #Const UseFastAlgorithm = True
        
        #If UseFastAlgorithm Then
           Console.WriteLine("Fast")
        #Else
           Console.WriteLine("Slow")
        #End If
   End Sub
End class
Slow
Fast