Wednesday, 13 April 2016

C# For Beginners Lesson 9 - Overview of the Visual Studio IDE


The canonical "hello, world" program can be written as follows:
using System;
class Hello
{
   static void Main() {
      Console.WriteLine("hello, world");
   }
}
The source code for a C# program is typically stored in one or more text files with a file extension of .cs, as in hello.cs. Using the command-line compiler provided with Visual Studio .NET, such a program can be compiled with the command-line directive
csc hello.cs
which produces an application named hello.exe. The output produced by this application when it is run is:
hello, world
Close examination of this program is illuminating:
  • The program does not use a global method for Main. Methods and variables are not supported at the global level; such elements are always contained within type declarations (e.g., class and struct declarations).
  • The program does not use either "::" or "->" operators. The "::" is not an operator at all, and the "->" operator is used in only a small fraction of programs — those that employ unsafe code (Section A). The separator "." is used in compound names such as Console.WriteLine.
  • The program does not contain forward declarations. Forward declarations are never needed, as declaration order is not significant.
  • The program does not use #include to import program text. Dependencies among programs are handled symbolically rather than textually. This approach eliminates barriers between applications written using multiple languages. For example, the Console class need not be written in C#.

No comments:

Post a Comment