最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
为自己的类添加说明文字
时间:2022-07-02 18:06:26 编辑:袖梨 来源:一聚教程网
教程
C# 提供一种机制,供开发人员使用 XML 将其代码存档。在源代码文件中,以下代码行可以作为注释处理并放在文件中:以 /// 开始的行;在用户定义的类型(如类、委托或接口)、某成员(如字段、事件、属性或方法)或某命名空间声明之前的行。
示例
下面的示例提供对某个已存档的类型的基本概述。若要编译该示例,请键入以下命令行:
csc XMLsample.cs /doc:XMLsample.xml
这将创建 XML 文件 XMLsample.xml,您可以在浏览器中或使用 TYPE 命令查看该文件。
// XMLsample.cs
// compile with: /doc:XMLsample.xml
using System;
///
/// Class level summary documentation goes here.
///
/// Longer comments can be associated with a type or member
/// through the remarks tag
public class SomeClass
{
///
/// Store for the name property
private string myName = null;
///
/// The class constructor.
public SomeClass()
{
// TODO: Add Constructor Logic here
}
///
/// Name property
///
/// A value tag is used to describe the property value
public string Name
{
get
{
if ( myName == null )
{
throw new Exception("Name is null");
}
return myName;
}
}
///
/// Description for SomeMethod.
/// Parameter description for s goes here
///
/// You can use the cref attribute on any tag to reference a type or member
/// and the compiler will check that the reference exists.
public void SomeMethod(string s)
{
}
C# 提供一种机制,供开发人员使用 XML 将其代码存档。在源代码文件中,以下代码行可以作为注释处理并放在文件中:以 /// 开始的行;在用户定义的类型(如类、委托或接口)、某成员(如字段、事件、属性或方法)或某命名空间声明之前的行。
示例
下面的示例提供对某个已存档的类型的基本概述。若要编译该示例,请键入以下命令行:
csc XMLsample.cs /doc:XMLsample.xml
这将创建 XML 文件 XMLsample.xml,您可以在浏览器中或使用 TYPE 命令查看该文件。
// XMLsample.cs
// compile with: /doc:XMLsample.xml
using System;
///
/// Class level summary documentation goes here.
///
/// Longer comments can be associated with a type or member
/// through the remarks tag
public class SomeClass
{
///
/// Store for the name property
private string myName = null;
///
/// The class constructor.
public SomeClass()
{
// TODO: Add Constructor Logic here
}
///
/// Name property
///
/// A value tag is used to describe the property value
public string Name
{
get
{
if ( myName == null )
{
throw new Exception("Name is null");
}
return myName;
}
}
///
/// Description for SomeMethod.
/// Parameter description for s goes here
///
/// You can use the cref attribute on any tag to reference a type or member
/// and the compiler will check that the reference exists.
public void SomeMethod(string s)
{
}
相关文章
- picacg游咔官方入口 02-04
- 咔哔漫画APP最新版本下载安装-哔咔漫画app安卓免费下载入口 02-04
- 哔咔漫画-正版漫画阅读平台-海量资源在线畅看-PicAcg官网 02-04
- 快看漫画免费下载安装最新版本-正版女生漫画APP官方入口安卓版 02-04
- 惜花芷电视剧免费观看完整版:正版平台观影建议与剧情全解析 02-04
- 超星网页版快捷登陆-超星学习通一键登录平台 02-04