Working with the Conditional Attribute : Attribute « Development Class « C# / C Sharp






Working with the Conditional Attribute

 


using System;
using System.Diagnostics;
   
public class TestClass
{
    public void Method1()
    {
        Console.WriteLine("Hello from Method1!");
    }
   
    [Conditional("DEBUG")]
    public void Method2()
    {
        Console.WriteLine("Hello from Method2!");
    }
   
    public void Method3()
    {
        Console.WriteLine("Hello from Method3!");
    }
   
}
   
class MainClass
{
    public static void Main()
    {
        TestClass MyTestClass = new TestClass();
   
        MyTestClass.Method1();
        MyTestClass.Method2();
        MyTestClass.Method3();
    }
}

 








Related examples in the same category