• Advertisement
Sign in to follow this  

C# Beginner Question - Visual Studio adds some stuff.

This topic is 4854 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, I'm trying to learn C# at school when I have access to the new .NET (I only have the free IDEs and I don't really like SharpDevelop that much). However, VS adds some stuff I don't know what it does / what its purpose is, and I was wondering if someone could give me a hand and if its neccessary for a Visual Studio app or not or what the deal is:
using System;

namespace Tic_Tac_Toe
{
	/// <summary>
	/// Summary description for Class1.
	/// </summary>
	class Class1
	{
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main(string[] args)
		{
			//
			// TODO: Add code to start application here
			//
		}
	}
}

Do I have to keep those summary comments? Or are they just for some fancy documentation that I'm never going to use anyways? But more importantly, what does [STAThread] do and is that neccessary?

Share this post


Link to post
Share on other sites
Advertisement
Those comments aren't necessary they are added by the application wizards that are part of VS. Although a auto documentor application like doxygen could be used to read those summary tags to produce class help files sort of an automatic documentation writer (sort of!). As for the [STAThread] bit this tells C# that the COM threading model for the application is single-threaded apartment (STA). I believe this entry is required if you plan on using COM object (ActiveX) in your application. Its probably best to leave it there.

Share this post


Link to post
Share on other sites
As above the stathread is to do with the threading model for the app, and the string[] args inside the main, is used when you want to pass command line arguments to the application.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement