Kiểu dữ liệu sizeof () trả về kích thước của một kiểu dữ liệu. Giả sử bạn cần tìm kích thước của kiểu dữ liệu int -
sizeof(int);
Đối với kiểu dữ liệu kép -
sizeof(double);
Hãy để chúng tôi xem ví dụ đầy đủ để tìm kích thước của các kiểu dữ liệu khác nhau -
Ví dụ
using System;
namespace Demo {
class Program {
static void Main(string[] args) {
Console.WriteLine("The size of long is {0}", sizeof(long));
Console.WriteLine("The size of double is {0}", sizeof(double));
Console.ReadLine();
}
}
} Đầu ra
The size of long is 8 The size of double is 8