首页 > 应用开发 > IT综合 > C# 语言规范--2.5.5 诊断指令(转)
诊断指令用于显式生成错误信息和警告消息,这些信息的报告方式与其他编译时错误和警告相同。
示例:
#warning Code review needed before check-in#if Debug && Retail #error A build can't be both debug and retail#endifclass Test {...}总是产生一个警告(“Code review needed before check-in”),如果同时定义条件符号 Debug 和 Retail,则产生一个编译时错误(“A build can't be both debug and retail”)。注意 pp-message(pp 消息)可以包含任意文本;具体说来,它可以包含格式不正确的标记,比如“can't”中的单引号就是这样。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/8781179/viewspace-924542/ ,如需转载,请注明出处,否则将追究法律责任。