1

A question of a beginner in c#

from net

using System; 
namespace mcMath 
{ 
/// <summary> 
/// Summary description for Class1. 
/// </summary> 
public class Class1 
{ 
public Class1() 
{ 
// 
// TODO: Add constructor logic here 
// 
} 
} 
} 

When I make project, I am getting

using System;    
namespace mcmath
{
    public class Class1
    {
    }
}

How can add by default comments, and default constructor. I mean

/// <summary> 
/// Summary description for Class1. 
/// </summary> 

public Class1() 
    { 
    // 
    // TODO: Add constructor logic here 
    // 
    } 

What I have to do. I am using VS 2008. Regards,

BenH
  • 2,100
  • 2
  • 22
  • 33
Shahgee
  • 3,303
  • 8
  • 49
  • 81
  • You are getting the "compiled source" without comments, that's ok, the comments would be in the xml file that goes with the compiled one... Why do you want the comments on the exe?? besides that is pre-compiled so can't have comments? – gbianchi Oct 07 '11 at 14:14
  • 1
    Just FYI, [GhostDoc](http://submain.com/products/ghostdoc.aspx) is a big time saver for generating vanilla comments and structure. – CodeNaked Oct 07 '11 at 14:15
  • possible duplicate of [How to have comments in IntelliSense for function in Visual Studio?](http://stackoverflow.com/questions/529677/how-to-have-comments-in-intellisense-for-function-in-visual-studio) – Roman Oct 07 '11 at 14:15
  • @gbianchi: Not really sure what you're referring to with "compiled source." It's fairly normal to have your XML comments be in the same file as your source code. Visual studio will even helpfully collapse them for you to not clutter your code. – Roman Oct 07 '11 at 14:18
  • @CodeNaked thanks for the GhostDoc link, been looking for something like that :) – Joshua Smith Oct 07 '11 at 14:19
  • @R0MANARMY - I don't believe that is a duplicate. I think the OP is referring to when the project/file is first added/created. – CodeNaked Oct 07 '11 at 14:34
  • @R0MANARMY Yes, I understand the question wrong.. after reading it a couple of time, I though that make, was build.. But the OP is referring at building a new source file (at least that what I think now).. Yes, you have right, the documentation is with the source ;) – gbianchi Oct 07 '11 at 14:41
  • @CodeNaked: Looks like you're right. – Roman Oct 07 '11 at 16:32

2 Answers2

1

Under the folder C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplates\CSharp\Windows\1033 are all the templates for C# windows projects. You'd have to unzip those, add the comments there, then re-zip them.

Then when you create a new project, the comments will be there.

Likewise, individual items can be found at C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\CSharp\.

If you don't want to change those versions, you can copy them to C:\Users\<UserName>\Documents\Visual Studio 2010\Templates. Just be sure to update the vstemplate file with new names and GUIDs.

CodeNaked
  • 40,753
  • 6
  • 122
  • 148
  • how to add by default constructor. – Shahgee Oct 07 '11 at 14:35
  • @shahbaba - Just updated my answer as you posted your comment. If you are adding a new file, then you'd need to look in ItemTemplates. If you are creating a new project, then you'd have to look in ProjectTemplates. But if you look in the zip files, there are `.cs` files that have the basic structure of the file (with some template parameters such as `$rootnamespace$`. – CodeNaked Oct 07 '11 at 14:39
0

Just click above the class decleration, and start typing 3 slashes: ///

They Visual studio IntelliSense will create the documentation template for you.

Yochai Timmer
  • 48,127
  • 24
  • 147
  • 185