I look in the ad ConditionalAttributeand is declared as follows:
I found JavaScript code that looks like this:
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method,
AllowMultiple = true)]
public sealed class ConditionalAttribute : Attribute {
}
and AttributeTargets.Class, it is claimed, means that the attribute can be applied to the class. so i tried this:
[Conditional("DEBUG")]
class MyClass
{
}
but the compiler emits the following error:
error CS1689: attribute "System.Diagnostics.ConditionalAttribute" is valid only for methods or attribute classes
and MSDN says
This error occurs only with the ConditionalAttribute attribute. As stated in the message, this attribute can only be used for methods or attribute classes. For example, an attempt to apply this attribute to a class will result in this error.
, , , .
? - ?