如何注释java/c#代码
本文关键字:java 代码 注释 何注释 | 更新日期: 2023-09-27 18:18:31
如果我有代码
static private String[][] getRssData(String channel)
{
//Code here...
}
是否有一种方法可以查看悬停功能的描述?即添加
//this is Using to get the RssData
我打算用c#和java编码来做这件事
在c#的Visual Studio IDE中,您可以使用XML文档:
///<summary>
///This is used to get the RSS data
///</summary>
///<param name="channel">The channel</param>
///<returns>The RSS data</returns>
private static string[][] GetRssData(string channel)
{
//...
}
你可以使用Android Studio中的[Javadoc]插件(http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html)在Java中做同样的事情:
/**
* This is used to get the RSS data
* @param channel The channel
* @return The RSS data
*/
static String[][] getRssData(String channel)
{
//...
}
在上面的c#类型///
中,方法和水根将自动生成
在c#中你可以这样做:
/// <summary>
/// this is Using to get the RssData
/// </summary>
static private string[][] GetRssData(string channel)
{
//Code here...
}
关于<summary>
的更多信息
/**
* this is Using to get the RssData
*/
static private string[][] getRssData(String channel)
{
//Code here...
}
在Java中,Javadoc注释是编写文档注释的首选方式。
把
/**
* Your comments go here.
*/
在方法头之前,IDE可能会显示html格式的注释。
同样,您可以使用javadoc工具为您的代码生成html文档,就像API一样。
下面是编写优秀javadoc注释的指南:http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html
是否有一种方法可以查看悬停功能的描述?
这是您正在使用的IDE的功能,而不是语言。如果你在记事本中查看源代码,你不可能得到悬停文本。
但是(例如)当您将鼠标悬停在源代码中的方法名称上时,Eclipse IDE可以在弹出窗口中格式化和显示方法的javadoc注释。(您不需要将javadoc后处理为HTML即可实现此功能。Eclipse动态地从源代码中提取相关的注释)