locked
what is this box bracket mean RRS feed

  • Question

  • i came accross some debugging info and it has statements in a box bracket. what does it mean? what is the significance of the stuff behind the box brackets.
    [Conditional("DEBUG")]




    [Conditional("DEBUG")]
    public static void LogOutput(string fn)
    {
        Debug.Listeners.Add(new TextWriterTraceListener(fn));
        DateTime dt=DateTime.Now;
        Debug.WriteLine("Debug Logging Initialized: "+dt.ToString());
    }
     
    Tuesday, January 13, 2009 4:00 PM

Answers

  • The Conditional attriute is kinda of a special one though. It controls if the function its put on ends up in the generated code while all other attributes just add meta data to the function, check this page for more info on the Conditional attirbute.
    Tuesday, January 13, 2009 10:10 PM

All replies

  • It is known as an "attribute".

    See http://msdn.microsoft.com/en-us/library/aa288059(VS.71).aspx for details.
    Tuesday, January 13, 2009 4:03 PM
  • The Conditional attriute is kinda of a special one though. It controls if the function its put on ends up in the generated code while all other attributes just add meta data to the function, check this page for more info on the Conditional attirbute.
    Tuesday, January 13, 2009 10:10 PM
  •  In plain English this block of code means that it will work only in DEBUG mode but not when you released your application. If it is not Debug, this block will be ignored.
    AlexB
    Tuesday, January 13, 2009 10:45 PM