我是C#的新手,正在读/*!*/一些看似奇怪的地方的代码.例如,类方法定义为:
protected override OptionsParser/*!*/ CreateOptionsParser()
protected override void ParseHostOptions(string/*!*/[]/*!*/ args)
Run Code Online (Sandbox Code Playgroud)
不幸的/*!*/是不可谷歌.这是什么意思?
Jar*_*Par 47
这可能是尝试将Spec#style注释转换为非Spec#build.的!Spec#中的注释表示该值不为null.作者可能试图指出返回值,args数组和args中的所有元素都是非空值.
规范#链接:
快速规范#概述:
Spec#是通过Microsoft Research Project创建的.Net语言.它是C#语言的扩展,它试图将代码契约嵌入到类型系统中.最突出的是非可空类型(在类型名称后面用!表示),检查异常和前/后条件.
我不太了解C#,因为它可能是一个特殊的符号,但我在任何支持开/关,多行注释标记的语言中使用类似的技术,以允许我快速评论和取消注释多行单个字符更改,如下所示:
/*!*/
this is live code (and will probably cause a compilation error)
/*!*/
/*!* /
this is commented code (and should never cause a compilation error)
/*!*/
Run Code Online (Sandbox Code Playgroud)
原因!是因为构造类似于/**文档工具使用的常见令牌.
当语言支持单行注释标记时,还有其他技术//(并且像C++和Java一样实现它们):
///* - opening comments can be commented-out so what follows isn't a comment.
this is live code
//*/ - closing comment are not commented-out by single-line comments.
Run Code Online (Sandbox Code Playgroud)
因此,您可以删除第一个单行注释标记//,以产生一种"切换":
/* this is now commented.
this is also commented.
//*/ this line is live code.
Run Code Online (Sandbox Code Playgroud)