Web and email hosting - CHAPTER 3 66 C# LANGUAGE FUNDAMENTALS Note

CHAPTER 3 66 C# LANGUAGE FUNDAMENTALS Note C# is a case-sensitive programming language. Therefore, Main is not the same as main , and Readline is not the same as ReadLine . Given this, be aware that all C# keywords are in lowercase (public, lock, global, and so on), while namespaces, types, and member names begin (by convention) with an initial capital letter and have capitalized any embedded words (e.g., Console.WriteLine, System.Windows.Forms.MessageBox, System.Data.SqlClient, and so on). In addition to the public and static keywords, this Main() method has a single parameter, which happens to be an array of strings (string[] args). Although you are not currently bothering to process this array, this parameter may contain any number of incoming command-line arguments (you ll see how to access them momentarily). The program logic of HelloClass is within Main() itself. Here, you make use of the Console class, which is defined within the System namespace. Among its set of members is the static WriteLine() which, as you might assume, pumps a text string to the standard output. You also make a call to Console.ReadLine() to ensure the command prompt launched by Visual Studio 2005 remains visible during a debugging session until you press the Enter key. Because this Main() method has been defined as returning an integer data type, we return zero (success) before exiting. Finally, as you can see from the HelloClass type definition, C- and C++-style comments have carried over into the C# language. Variations on the Main() Method The previous iteration of Main() was defined to take a single parameter (an array of strings) and return an integer data type. This is not the only possible form of Main(), however. It is permissible to construct your application s entry point using any of the following signatures (assuming it is contained within a C# class or structure definition): // No return type, array of strings as argument. public static void Main(string[] args) { } // No return type, no arguments. public static void Main() { } // Integer return type, no arguments. public static int Main() { } Note The Main() method may also be defined as private as opposed to public. Doing so ensures other assemblies cannot directly invoke an application s entry point. Visual Studio 2005 automatically defines a program s Main() method as private. Obviously, your choice of how to construct Main() will be based on two questions. First, do you need to process any user-supplied command-line parameters? If so, they will be stored in the array of strings. Second, do you want to return a value to the system when Main() has completed? If so, you need to return an integer data type rather than void.
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.

Leave a Reply