c和代码标签之间的区别

时间:2011-10-31 13:01:48

标签: c# xml-comments

在C#xml评论中,下面的标签之间有什么区别?

1. <c> 
2. <code>

3 个答案:

答案 0 :(得分:5)

假设您在讨论tags in xml commentsc就像StackOverflow中的反向标记一样,而code更像是代码块。

/// <summary>
/// This is the <c>SomeMethod</c> method of the <c>Program</c> class.
/// </summary>
/// <param name="s">A string.</param>
/// <example>
/// You can use this method like this:
/// <code>
/// string x = SomeMethod("foobar");
/// Console.WriteLine(x);
/// </code>
/// </example>
static string SomeMethod(string s){
    throw new NotImplementedException();
} 

答案 1 :(得分:3)

<c>Your code sample.</c>    

表示一小段代码。您将使用c标记在结果文档中引起对特定单词,短语或代码的注意。您将c标记嵌套在其他标记中。

<code>Your code sample.</code>  

代码标记与标记类似,但它旨在说明真正的代码用法示例。代码标记通常包含在标记集中(见下文)。

答案 2 :(得分:3)

如果您在代码评论中表示意思,那么<code>(通常在<example>中使用)代表多行说明性代码,其中 - <c>仅表示要写入的单个术语代码字体。

使用stackoverflow / markdown作为比较,它们与paragrah中间的inline code完全相同,vs

a multi-line
code sample that
appears formatted separately
相关问题