Scrigroup - Documente si articole

     

HomeDocumenteUploadResurseAlte limbi doc
AccessAdobe photoshopAlgoritmiAutocadBaze de dateCC sharp
CalculatoareCorel drawDot netExcelFox proFrontpageHardware
HtmlInternetJavaLinuxMatlabMs dosPascal
PhpPower pointRetele calculatoareSqlTutorialsWebdesignWindows
WordXml


Getting started

C sharp



+ Font mai mare | - Font mai mic



Getting started

The canonical "hello, world" program can be written as follows:

using System;

class Hello

}

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, such a program can be compiled with the command line directive



csc hello.cs

which produces an executable program named hello.exe. The output of the program is:

hello, world

Close examination of this program is illuminating:

         The using System; directive references a namespace called System that is provided by the Microsoft .NET Framework class library. This namespace contains the Console class referred to in the Main method. Namespaces provide a hierarchical means of organizing the elements of a class library or program. A "using" directive enables unqualified use of the types that are members of the namespace. The "hello, world" program uses Console.WriteLine as a shorthand for System.Console.WriteLine.

         The Main method is a member of the class Hello. It has the static modifier, and so it is a method on the class Hello rather than on instances of this class.

         The main entry point for a program-the method that is called to begin execution-is always a static method named Main.

         The "hello, world" output is produced through the use of a class library. The language does not itself provide a class library. Instead, it uses a common class library that is also used by languages such as Visual Basic and Visual C++.

For C and C++ developers, it is interesting to note a few things that do not appear in the "hello, world" program.

         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. 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 programs written in different languages. For example, the Console class could be written in another language.



Politica de confidentialitate | Termeni si conditii de utilizare



DISTRIBUIE DOCUMENTUL

Comentarii


Vizualizari: 1029
Importanta: rank

Comenteaza documentul:

Te rugam sa te autentifici sau sa iti faci cont pentru a putea comenta

Creaza cont nou

Termeni si conditii de utilizare | Contact
© SCRIGROUP 2024 . All rights reserved