以下、個人用メモです。たまに忘れるので・・・w
' vim:set ts=4 sw=4 et ws is nowrap ft=vbnet: imports System namespace Tmp public class Sample public sub Execute() Console.WriteLine("HELLO Visual Basic.") #if DEBUG then Console.WriteLine("DEBUG:HELLO Visual Basic.") #else Console.WriteLine("HELLO Visual Basic 2.") #end if end sub shared sub Main() dim obj as new Sample() obj.Execute() end sub end class end namespace
// vim:set ts=4 sw=4 et ws is nowrap ft=cs: using System; namespace Tmp{ public class Sample{ static void Main(){ Console.WriteLine("HELLO C#"); #if(DEBUG) Console.WriteLine("HELLO C#(DEBUG)"); #else Console.WriteLine("HELLO C# 2."); #endif } } }
VisualStudioを使っている場合は、プロジェクトのプロパティの部分からDEBUGをONにする。
コマンドラインにてコンパイルしている場合は、
vbc Sample.vb /define:DEBUG
とする。
ついでに、メソッド単位で切り替える場合はConditional属性を使用する。