Csharp/C Sharp/Language Basics/sizeof — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 15:31, 26 мая 2010
You must declare that code that uses the sizeof operator as unsafe.
class SomeClass
{
static unsafe public void ShowSizes()
{
Console.WriteLine("\nBasic type sizes");
Console.WriteLine("sizeof short = {0}", sizeof(short));
Console.WriteLine("sizeof int = {0}", sizeof(int));
Console.WriteLine("sizeof long = {0}", sizeof(long));
Console.WriteLine("sizeof bool = {0}", sizeof(bool));
}
}
class SizeofBasicTypesApp
{
unsafe public static void Main(string[] args)
{
SomeClass.ShowSizes();
}
}