Csharp/CSharp Tutorial/Language Basics/Intrduction — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
м (1 версия)
 
(нет различий)

Текущая версия на 12:19, 26 мая 2010

A C# program begins with a call to Main()

This is a simple C# program.

Call this program Example.cs.


using System; 
 
class MainClass { 
   
  public static void Main() { 
    Console.WriteLine("A simple C# program."); 
  } 
}
A simple C# program.

C# has the following reserved keywords:

abstract              as                base                    bool                 break
byte                  case              catch                   char                 checked
class                 const             continue                decimal              default
delegate              do                double                  else                 enum
event                 explicit          extern                  false                finally
fixed                 float             for                     foreach              goto
if                    Implicit          In                      Int                  Interface
Internal              Is                lock                    long                 namespace
new                   null              object                  operator             out
override              params            private                 protected            public
readonly              ref               return                  sbyte                sealed
short                 sizeof            stackalloc              static               string
struct                switch            this                    throw                true
try                   typeof            uint                    ulong                unchecked
unsafe                ushort            using                   virtual              void
volatile              while

The C# Keywords

abstract      as         base          bool         break
Byte          case       catch         char         checked
class         const      continue      decimal      default
delegate      do         double        else         enum
event         explicit   extern        false        finally
fixed         float      for           foreach      goto
if            implicit   in            int          interface
internal      is         lock          long         namespace
new           null       object        operator     out
override      params     private       protected    public
readonly      ref        return        sbyte        sealed
short         sizeof     stackalloc    static       string
struct        switch     this          throw        true
try           typeof     uint          ulong        unchecked
unsafe        ushort     using         virtual      volatile
void          while

Using csc.exe, the C# Command-Line Compiler

To create and run programs using the C# command-line compiler:

  1. Enter the program using a text editor.
  2. Compile the program.
  3. Run the program.

Compiling the Program

C:\>csc Example.cs

Prior to running csc.exe, you may need to run the batch file vcvars32.bat, which is typically found in the //Program Files/Microsoft Visual Studio.NET/Vc7/Bin directory.

  1. The name of a C# program is arbitrary
  2. By convention, C# programs use the .cs file extension

1.1.Intrduction 1.1.1. <A href="/Tutorial/CSharp/0020__Language-Basics/ACprogrambeginswithacalltoMain.htm">A C# program begins with a call to Main()</a> 1.1.2. Using csc.exe, the C# Command-Line Compiler 1.1.3. <A href="/Tutorial/CSharp/0020__Language-Basics/TheCKeywords.htm">The C# Keywords </a> 1.1.4. <A href="/Tutorial/CSharp/0020__Language-Basics/Chasthefollowingreservedkeywords.htm">C# has the following reserved keywords:</a>