logo
CSharp_Prog_Guide

Компиляция и выполнение

Для компиляции программы "Hello World!" можно создать проект в среде IDE Visual Studio или воспользоваться командной строкой. Используйте средство командной строки Visual Studio или вызовите vsvars32.bat, чтобы в пути в командной строке открыть средство Visual C#.

Компиляция программы из командной строки.

csc Hello.cs

Если программа не содержит ошибок компиляции, то компилятор создает файл Hello.exe.

Hello

General Structure of a C# Program

C# programs can consist of one or more files. Each file can contain zero or more namespaces. A namespace can contain types such as classes, structs, interfaces, enumerations, and delegates, in addition to other namespaces. The following is the skeleton of a C# program that contains all of these elements.

// A skeleton of a C# program

using System;

namespace YourNamespace

{

class YourClass

{

}

struct YourStruct

{

}

interface IYourInterface

{

}

delegate int YourDelegate();

enum YourEnum

{

}

namespace YourNestedNamespace

{

struct YourStruct

{

}

}

class YourMainClass

{

static void Main(string[] args)

{

//Your program starts here...

}

}

}