共用方式為


<example> (Visual C++)

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at <example> (Visual C++).

The <example> tag lets you specify an example of how to use a method or other library member. Commonly, this would also involve use of the <code> tag.

Syntax

<example>description</example>  

Parameters

description
A description of the code sample.

Remarks

Compile with /doc to process documentation comments to a file.

Example

// xml_example_tag.cpp  
// compile with: /clr /doc /LD  
// post-build command: xdcmake xml_example_tag.dll  
  
/// Text for class MyClass.  
public ref class MyClass {  
public:  
   /// <summary>  
   /// GetZero method  
   /// </summary>  
   /// <example> This sample shows how to call the GetZero method.  
   /// <code>  
   /// int main()   
   /// {  
   ///    return GetZero();  
   /// }  
   /// </code>  
   /// </example>  
   static int GetZero() {  
      return 0;  
   }  
};  

See Also

XML Documentation