C# programları bir veya daha fazla dosyadan oluşur. Her dosya sıfır veya daha fazla ad alanı içerir.
Ad alanı; sınıflar, yapılar, arabirimler, numaralar ve temsilciler veya diğer ad alanları gibi türleri içerir. Aşağıdaki örnek, bu öğelerin hepsini içeren bir C# programının iskeletidir.
PHP- Kodu
// A skeleton of a C# program
using System;
// Your program starts here:
Console.WriteLine("Hello world!");
namespace YourNamespace
{
class YourClass
{
}
struct YourStruct
{
}
interface IYourInterface
{
}
delegate int YourDelegate();
enum YourEnum
{
}
namespace YourNestedNamespace
{
struct YourStruct
{
}
}
}
Yukarıdaki örnek, programın giriş noktası için üst düzey deyimleri kullanır. Bu özellik
C# 9'da eklendi.
C# 9'dan önce, giriş noktası aşağıdaki örnekte gösterildiği gibi
Main adlı
statik bir yöntemdi:
PHP- Kodu
// 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)
{
//Your program starts here...
Console.WriteLine("Hello world!");
}
}
}
Kaynak :
[Üye Olmadan Linkleri Göremezsiniz. Üye Olmak için TIKLAYIN...]