Događaj
Izgradite inteligentne aplikacije
17. mar 23 - 21. mar 23
Pridružite se seriji sastanaka kako biste izgradili skalabilna AI rešenja zasnovana na stvarnim slučajevima korišćenja sa kolegama programerima i stručnjacima.
Registrujte se odmahOvaj pregledač više nije podržan.
Nadogradite na Microsoft Edge biste iskoristili najnovije funkcije, bezbednosne ispravke i tehničku podršku.
C# programs consist of one or more files. Each file contains zero or more namespaces. A namespace contains types such as classes, structs, interfaces, enumerations, and delegates, or other namespaces. The following example is the skeleton of a C# program that contains all of these elements.
using System;
Console.WriteLine("Hello world!");
namespace YourNamespace
{
class YourClass
{
}
struct YourStruct
{
}
interface IYourInterface
{
}
delegate int YourDelegate();
enum YourEnum
{
}
namespace YourNestedNamespace
{
struct YourStruct
{
}
}
}
The preceding example uses top-level statements for the program's entry point. Only one file can have top-level statements. The program's entry point is the first line of program text in that file. In this case, it's the Console.WriteLine("Hello world!");
.
You can also create a static method named Main
as the program's entry point, as shown in the following example:
// 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 Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello world!");
}
}
}
In that case the program will start in the first line of Main
method, which is Console.WriteLine("Hello world!");
You learn about these program elements in the types section of the fundamentals guide:
For more information, see Basic concepts in the C# Language Specification. The language specification is the definitive source for C# syntax and usage.
Povratne informacije za .NET
.NET je projekat otvorenog koda. Izaberite vezu da biste pružili povratne informacije:
Događaj
Izgradite inteligentne aplikacije
17. mar 23 - 21. mar 23
Pridružite se seriji sastanaka kako biste izgradili skalabilna AI rešenja zasnovana na stvarnim slučajevima korišćenja sa kolegama programerima i stručnjacima.
Registrujte se odmahObuka
Modul
Write your first C# code - Training
Get started by writing code examples to learn the basics of the C# syntax.
Dokumentacija
C# docs - get started, tutorials, reference.
Learn C# programming - for beginning developers, developers new to C#, and experienced C# / .NET developers
New to C#? Learn the basics of the language. Start with this overview.
Learn the fundamentals of the C# type system - C#
Learn about creating types in C#, such as tuples, records, value types, and reference types. Learn to choose between these options.