如何在C#中向类、方法、属性等添加文档工具提示?
我甚至不确定我是否正确地调用了它,但我想开始向我的类、方法、属性等添加一些文档。我知道这可能是非常明显的,但我从未真正了解过。我不知道从哪里开始 为了澄清,无论何时滚动类(或方法、属性等),它都会在VisualStudio中显示一个工具提示,其中包含有关该特定方法的一些文档 类Microsoft.Phone.BackgroundAudio.BackgroundAudioPlayer如何在C#中向类、方法、属性等添加文档工具提示?,c#,.net,visual-studio,documentation,C#,.net,Visual Studio,Documentation,我甚至不确定我是否正确地调用了它,但我想开始向我的类、方法、属性等添加一些文档。我知道这可能是非常明显的,但我从未真正了解过。我不知道从哪里开始 为了澄清,无论何时滚动类(或方法、属性等),它都会在VisualStudio中显示一个工具提示,其中包含有关该特定方法的一些文档 类Microsoft.Phone.BackgroundAudio.BackgroundAudioPlayer 提供对音频播放功能(如播放、暂停、快进和快退)的后台访问 调用什么以及如何在我的C#应用程序中实现它?在类、方法或
提供对音频播放功能(如播放、暂停、快进和快退)的后台访问
调用什么以及如何在我的C#应用程序中实现它?在类、方法或属性上方,键入
//
,然后按return。这将为您生成文档模板
忘记回答问题的另一部分:这被称为,MSDN中有大量关于这一点的信息。您可以使用///或
编辑:
在第一种情况下,你会得到
/// <summary>
///
/// </summary>
class A
{
/// <summary>
///
/// </summary>
public A() { }
/// <summary>
///
/// </summary>
public int Property { get; set; }
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
public void Method(object obj) { }
}
//
///
///
甲级
{
///
///
///
公共A(){}
///
///
///
公共int属性{get;set;}
///
///
///
///
公共无效方法(对象obj){}
}
秒
/// <summary>
///
/// </summary>
class B
{
/// <summary>
/// Initializes a new instance of the <see cref="B"/> class.
/// </summary>
public B() { }
/// <summary>
/// Gets or sets the property.
/// </summary>
/// <value>
/// The property.
/// </value>
public int Property { get; set; }
/// <summary>
/// Methods the specified obj.
/// </summary>
/// <param name="obj">The obj.</param>
public void Method(object obj) { }
}
//
///
///
B类
{
///
///初始化类的新实例。
///
公共B(){}
///
///获取或设置属性。
///
///
///财产。
///
公共int属性{get;set;}
///
///方法采用指定的obj。
///
///obj。
公共无效方法(对象obj){}
}
您所指的是XML文档或XML文档
XML文档在类、字段、属性、事件或方法上执行时使用三个正斜杠(//
),后跟关于类或其成员的XML格式的元信息
VS将通过内置的IntelliSense对XML注释的支持来帮助您生成和格式化这些注释,但有一个名为的免费工具将自动生成完整的XML文档模板,在某些情况下,它甚至“聪明”到可以尝试猜测文档各种元素的基本描述
下面是XML文档的一个基本示例:
/// <summary>
/// Defines the behavior of a class following the Repository pattern for data access
/// with basic atomic operation control.
/// </summary>
/// <typeparam name="TRest">An interface derived from IDomainObject that describes domain objects
/// that can be retrieved or saved by this Repository.</typeparam>
public interface IRepository<TRest> : IDisposable where TRest : IDomainObject
{
/// <summary>
/// Begins a new unit of work to be performed atomically by the Repository.
/// </summary>
/// <returns>A token class representing the unit of work.</returns>
IUnitOfWork BeginUnitOfWork();
/// <summary>
/// Commits all work performed under the specified unit of work.
/// </summary>
/// <param name="unitOfWork">The unit of work.</param>
void CommitUnitOfWork(IUnitOfWork unitOfWork);
/// <summary>
/// Rolls back the specified unit of work.
/// </summary>
/// <param name="unitOfWork">The unit of work.</param>
void RollBackUnitOfWork(IUnitOfWork unitOfWork);
/// <summary>
/// Saves the specified domain object to the data source controlled by the repository.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="domainObject">The domain object.</param>
/// <param name="unitOfWork">The unit of work.</param>
void Save<T>(T domainObject, IUnitOfWork unitOfWork) where T : class, TRest;
/// <summary>
/// Begins a Linq query for a specific object type, to be performed against the Repository's data source.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="unitOfWork">The unit of work.</param>
/// <returns>An IQueryable representing the query to be performed.</returns>
IQueryable<T> QueryFor<T>(IUnitOfWork unitOfWork) where T : class, TRest;
/// <summary>
/// Performs the specified Action using a new unit of work, with commits and rollbacks as necessary.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="func">The Action to perform. The lambda or named method must accept an IUnitOfWork as a parameter.</param>
/// <param name="commit">if set to <c>true</c>, commit the unit of work.</param>
void PerformInNewUnitOfWork<T>(Action<IUnitOfWork> func, bool commit = false);
/// <summary>
/// Performs the specified Func using a new unit of work, with commits and rollbacks as necessary.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="func">The function to evaluate. The lambda or named method must accept an IUnitOfWork as a parameter.</param>
/// <returns>A single object of the generic type, returned by the function.</returns>
/// <param name="commit">if set to <c>true</c>, commit the unit of work.</param>
T PerformInNewUnitOfWork<T>(Func<IUnitOfWork, T> func, bool commit = false) where T : class, TRest;
/// <summary>
/// Performs the specified Func using a new unit of work, with commits and rollbacks as necessary.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="func">The Function to evaluate. The lambda or named method must accept an IUnitOfWork as a parameter.</param>
/// <returns>An enumerable set of objects of the generic type, returned by the function.</returns>
/// <param name="commit">if set to <c>true</c>, commit the unit of work.</param>
IEnumerable<T> PerformInNewUnitOfWork<T>(Func<IUnitOfWork, IEnumerable<T>> func, bool commit = false) where T : class, TRest;
/// <summary>
/// Attaches the specified domain object to the current Unit of Work, allowing operations to be performed on it.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="domainObject">The domain object.</param>
/// <param name="unitOfWork">The unit of work.</param>
void Attach<T>(T domainObject, IUnitOfWork unitOfWork) where T : class, TRest;
/// <summary>
/// Detaches the specified domain object to the current Unit of Work.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="domainObject">The domain object.</param>
/// <param name="unitOfWork">The unit of work.</param>
void Detach<T>(T domainObject, IUnitOfWork unitOfWork) where T : class, TRest;
/// <summary>
/// Refreshes the specified collection of persistent elements with the most recent persisted data.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="elements">The list of elements to refresh.</param>
/// <param name="unitOfWork">The Unit of Work under which to perform the operation.</param>
void Refresh<T>(IList<T> elements, IUnitOfWork unitOfWork) where T : class, TRest;
/// <summary>
/// Deletes the specified domain object from the data store.
/// Usually performs a physical delete; logical deletes are most often done through updates.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="domainObject">The domain object to delete.</param>
/// <param name="unitOfWork">The unit of work under which to perform the operation.</param>
void Delete<T>(T domainObject, IUnitOfWork unitOfWork) where T : class, TRest;
}
//
///定义按照存储库模式进行数据访问的类的行为
///具有基本的原子操作控制。
///
///从描述域对象的IDomainObject派生的接口
///可由此存储库检索或保存的。
公共接口IRepository:IDisposable其中TRest:IDomainObject
{
///
///开始由存储库以原子方式执行的新工作单元。
///
///表示工作单元的令牌类。
i工作开始工作();
///
///提交指定工作单元下执行的所有工作。
///
///工作单位。
无效委托工作(i工作单元);
///
///回滚指定的工作单元。
///
///工作单位。
无效回滚unitOfWork(IUnitOfWork unitOfWork);
///
///将指定的域对象保存到存储库控制的数据源。
///
///
///域对象。
///工作单位。
void Save(T domainObject,IUnitOfWork unitOfWork),其中T:class,TRest;
///
///开始针对特定对象类型的Linq查询,该查询将针对存储库的数据源执行。
///
///
///工作单位。
///表示要执行的查询的IQueryable。
(IUnitOfWork unitOfWork)的可查询查询,其中T:class,TRest;
///
///使用新的工作单元执行指定的操作,并根据需要执行提交和回滚。
///
///
///要执行的操作。lambda或命名方法必须接受IUnitOfWork作为参数。
///如果设置为true,则提交工作单元。
void PerformInNewUnitOfWork(Action func,bool commit=false);
///
///使用新的工作单元执行指定的Func,并根据需要执行提交和回滚。
///
///
///要计算的函数。lambda或命名方法必须接受IUnitOfWork作为参数。
///函数返回的泛型类型的单个对象。
///如果设置为true,则提交工作单元。
T PerformInNewUnitOfWork(Func-Func,bool-commit=false),其中T:class,TRest;
///
///使用新的工作单元执行指定的Func,并根据需要执行提交和回滚。
///
///
///要计算的函数。lambda或命名方法必须接受IUnitOfWork作为参数。
///函数返回的泛型类型的可枚举对象集。
///如果设置为true,则提交工作单元。
IEnumerable performinNewwUnitofWork(Func-Func,bool-commit=false),其中T:class,TRest;
///
///将指定的域对象附加到当前工作单元,从而允许对其执行操作。
///
///
///域对象。
///工作单位。
void Attach(T domainObject,IUnitOfWork unitOfWork),其中T:class,TRest;
///
///将指定的域对象分离到当前工作单元。
///
///
///域对象。
///工作单位。
void Detach(T domainObject,IUnitOfWork unitOfWork),其中T:class,TRest;
///
///使用最新的持久化数据刷新指定的持久化元素集合。
///
///
///要刷新的元素列表。
///在其下执行操作的工作单元。
void Refresh(IList元素,IUnitOfWork unitOfWork),其中T:class,TRest;
///
///从数据存储中删除指定的域对象。
///通常执行物理删除;逻辑删除通常通过