Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 许多常量的XML文档_C#_Documentation_Sandcastle - Fatal编程技术网

C# 许多常量的XML文档

C# 许多常量的XML文档,c#,documentation,sandcastle,C#,Documentation,Sandcastle,有没有办法将XML文档摘要标记与类中的常量放在同一行上 我有一个定义了许多常量返回值的类,每个类之间都有注释行,这使得读取和维护有点困难。(同样的问题也适用于枚举值。) 下面的代码显示了我的代码现在的样子。如果有办法的话,我想保持这样 public class MyUtilClass { public static int UTIL_SUCCESS = 0; // This is an example comment for success. public

有没有办法将XML文档摘要标记与类中的常量放在同一行上

我有一个定义了许多常量返回值的类,每个类之间都有注释行,这使得读取和维护有点困难。(同样的问题也适用于枚举值。)

下面的代码显示了我的代码现在的样子。如果有办法的话,我想保持这样

public class MyUtilClass
{
    public static int  UTIL_SUCCESS         = 0;   // This is an example comment for success.
    public static int  UTIL_WARNING_LEVEL_1 = 1;   // This is an example comment for warning level 1.
    public static int  UTIL_WARNING_LEVEL_2 = 2;   // This is an example comment for warning level 2.
    public static int  UTIL_FAILED          = 3;   // This is an example comment for failure.
}
我正在使用生成我的文档


谢谢

不,我认为您必须将XML文档包含在它所记录的内容之上。但是,您可以将摘要标记及其内容放在一行上:

/// <summary>Some content</summary>
public static int  UTIL_SUCCESS         = 0;
///一些内容
公共静态int UTIL_SUCCESS=0;

在每个常量上方使用XML注释;它们具有智能感知功能,您可以在自动化文档工具(包括Sandcastle)中使用它们。VS、Sandcastle和intellisense都希望评论超出他们所指的元素。是的,我就是这么做的,但我特别问是否有人知道在同一条线上做这件事的方法。一旦你有了很多常量,不管它们是字符串还是数值,这个列表就很难用它们之间的注释来维护了。如果常量的数量变得太多,请将其放入自己的类中。看起来应该是
枚举
,而不是带有常量的类。