好的注释应该怎么样写?

我是一名C#初学者,老师让编码和注释一样多,这我就迷茫了;能有这么多注释吗?寻求大神们知道

每个方法写类似这样的注释

 /**
     * 添加3D素材
     * @param material
     * @return
     * @createtime 2015年6月17日 下午3:37:38
     * @author Feyond
     */

实现方法的过程中写上别人一时难以理解的代码注释

以第三者的观点去看代码时觉得不懂的就改写直接,方法写注释如一楼就差不多了

有些极端了,关键部分要有注释,每个类每个方法必须注释

1.简单代码或脚本,遵循命名规范,可以不写注释,文件开始写明作用即可。关键部分写简单注释。
2.由多个文件组成的复杂项目结构,文件开始的说明最好由工具生成,类方法的输入输出要标明。
3.如果是开源项目,那情况又完全不一样了,注释简直是越多越好,“为什么这么做”也越多越好。

注释的数量应当适中,太多的注释会让代码看起来很杂乱,太少的注释不利与代码的阅读,所以,只有主要的方法和难以理解的代码才需要注释,一般来说,注释大约占代码的1/3就够了。

关键地方注释就好,太多反而容易使人晕。

http://blog.csdn.net/evankaka/article/details/46538109

业务逻辑复杂的地方需要加,担心其他人看比较费劲的地方也加一下!

代码中的注释是为了增强其可读性,因为一个软件开发的主要成本在于维护,所以明确,高效的注释必不可少。但前提是注释的正确性,精简性要尽量写好。望有帮助。

我是一名C#初学者,老师让编码和注释一样多,这我就迷茫了;能有这么多注释吗?

你的老师智商捉急。

你可以看看微软自己的.net源代码,没有多少注释的。

http://referencesource.microsoft.com/

看代码能看明白的,千万不要额外加注释。
注释应该解释实现意图,而不是怎么做,代码是用来解释怎么做的。

比如:

 //------------------------------------------------------------------------------
// <copyright file="DesignerCalendarAdapter.cs" company="Microsoft">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>                                                                
//------------------------------------------------------------------------------

using System.Diagnostics;
using System.Drawing;
using System.Web.Mobile;
using System.Web.UI.Design.MobileControls;
using System.Web.UI.MobileControls;
using System.Web.UI.MobileControls.Adapters;

namespace System.Web.UI.Design.MobileControls.Adapters
{
    [
        System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand,
        Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)
    ]
    [Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
    internal class DesignerCalendarAdapter : HtmlCalendarAdapter
    {
        public override MobileCapabilities Device
        {
            get
            {
                return DesignerCapabilities.Instance;
            }
        }

        public override void Render(HtmlMobileTextWriter writer)
        {
            writer.WriteBeginTag("div");
            String width = DesignerAdapterUtil.GetWidth(Control);

            writer.WriteAttribute("style", "cellpadding=2px;width:" + width);

            Alignment alignment = (Alignment)Style[Style.AlignmentKey, true];
            if (alignment != Alignment.NotSet)
            {
                writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment));
            }
            writer.Write("/>");

            ((DesignerTextWriter)writer).EnterZeroFontSizeTag();

            //Note: Although this is an internal method of runtime, but it is still
            //      pretty easy to achieve the same goal without using this method.
            Style.ApplyTo(Control.WebCalendar);
            base.Render(writer);

            ((DesignerTextWriter)writer).ExitZeroFontSizeTag();
            writer.WriteEndTag("div");
        }
    }
}

http://referencesource.microsoft.com/#System.Web.Mobile/UI/MobileControls/Design/Adapters/DesignerCalendarAdapter.cs,3ebd20d8ddf13028

这里只有一处注释

在普通代码处无需添加注释,较为复杂的结构中适当添加以利于他人或自己后期维护,注明为什么做、怎么做