C# Beginner Question - Visual Studio adds some stuff.

Started by
1 comment, last by Mykre 19 years, 3 months ago
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?
"Where genius ends, madness begins."Estauns
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.
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.
Mykre - BlogVirtual Realm :- XNA News and Resources from Down Under** For those Interested in an Australian XNA User Group Contact me though my site.

This topic is closed to new replies.

Advertisement