Condividi tramite


<summary> (Guida per programmatori C#)

<summary>description</summary>

Parametri

  • description
    Riepilogo relativo all'oggetto.

Note

Il tag <summary> deve essere utilizzato per descrivere un tipo o un membro del tipo. Utilizzare <remarks> per aggiungere informazioni supplementari alla descrizione di un tipo. Utilizzare l'attributo cref per abilitare strumenti della documentazione come Sandcastle per creare collegamenti ipertestuali interni alle pagine della documentazione per gli elementi di codice.

Il testo del tag <summary> rappresenta l'unica fonte di informazioni sul tipo in IntelliSense e viene visualizzato anche nel Object Browser Window.

Eseguire la compilazione con /doc per elaborare in un file i commenti per la creazione della documentazione. Per creare la documentazione finale basata sul file generato dal compilatore, è possibile creare uno strumento personalizzato o utilizzare uno strumento come Sandcastle.

Esempio

// compile with: /doc:DocFileName.xml  

/// text for class TestClass 
public class TestClass
{
    /// <summary>DoWork is a method in the TestClass class. 
    /// <para>Here's how you could make a second paragraph in a description. <see cref="System.Console.WriteLine(System.String)"/> for information about output statements.</para>
    /// <seealso cref="TestClass.Main"/>
    /// </summary> 
    public static void DoWork(int Int1)
    {
    }

    /// text for Main 
    static void Main()
    {
    }
}

Nell'esempio precedente produce il seguente file XML.

<?xml version="1.0"?>
<doc>
    <assembly>
        <name>YourNamespace</name>
    </assembly>
    <members>
        <member name="T:DotNetEvents.TestClass">
            text for class TestClass
        </member>
        <member name="M:DotNetEvents.TestClass.DoWork(System.Int32)">
            <summary>DoWork is a method in the TestClass class.
            <para>Here's how you could make a second paragraph in a description. <see cref="M:System.Console.WriteLine(System.String)"/> for information about output statements.</para>
            <seealso cref="M:DotNetEvents.TestClass.Main"/>
            </summary>
        </member>
        <member name="M:DotNetEvents.TestClass.Main">
            text for Main
        </member>
    </members>
</doc>

Nell'esempio riportato di seguito viene illustrato come effettuare un riferimento cref a un tipo generico.

// compile with: /doc:DocFileName.xml  

// the following cref shows how to specify the reference, such that, 
// the compiler will resolve the reference 
/// <summary cref="C{T}">
/// </summary> 
class A { }

// the following cref shows another way to specify the reference,  
// such that, the compiler will resolve the reference 
// <summary cref="C &lt; T &gt;">

// the following cref shows how to hard-code the reference 
/// <summary cref="T:C`1">
/// </summary> 
class B { }

/// <summary cref="A">
/// </summary> 
/// <typeparam name="T"></typeparam>
class C<T> { }

Nell'esempio precedente produce il seguente file XML.

<?xml version="1.0"?>
<doc>
    <assembly>
        <name>YourNamespace</name>
    </assembly>
    <members>
        <member name="T:ExtensionMethodsDemo1.A">
            <summary cref="T:ExtensionMethodsDemo1.C`1">
            </summary>
        </member>
        <member name="T:ExtensionMethodsDemo1.B">
            <summary cref="T:C`1">
            </summary>
        </member>
        <member name="T:ExtensionMethodsDemo1.C`1">
            <summary cref="T:ExtensionMethodsDemo1.A">
            </summary>
            <typeparam name="T"></typeparam>
        </member>
    </members>
</doc>

Vedere anche

Riferimenti

Tag consigliati per i commenti relativi alla documentazione (Guida per programmatori C#)

Concetti

Guida per programmatori C#