C# 中 sizeof 運算子的作用是什麼?
sizeof() 資料型別返回資料型別的大小。假設你需要找到 int 資料型別的大小 −
sizeof(int);
對於 double 資料型別 −
sizeof(double);
讓我們看一個完整的示例來找到各種資料型別的大小 −
示例
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();
}
}
}輸出
The size of long is 8 The size of double is 8
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP