Use the Conditional attribute to make a method non-callable in C#

[Conditional("DIAG")]To define a compilation constant, open the Project menu, select Properties, click the Build tab, and enter DIAG or TEST in the "Conditional compilation constants" box. If a method is not callable, Visual Basic still generates code for it and still checks the calling routine's parameters against those required by the method, but it does not perform the call at run time. You can use #if to exclude code from compilation but if you exclude a method in this way, any code that calls the method will generate an error. Using Conditional allows you to hide a method safely.
[Conditional("TEST")]
private void Test()
{
MessageBox.Show("Test", "Test", MessageBoxButtons.OK);
}


-->
Comments