C#中的一元运算符是什么?
以下是C#中的一元运算符-
+ - ! ~ ++ -- (type)* & sizeof
让我们了解sizeof运算符。sizeof返回数据类型的大小。
假设您需要找到int数据类型的大小-
sizeof(int)
对于双数据类型-
sizeof(double)
让我们看看完整的示例以查找各种数据类型的大小-
示例
using System;
namespace Demo {
class Program {
static void Main(string[] args) {
Console.WriteLine("The size of int is {0}", sizeof(int));
Console.WriteLine("The size of int is {0}", sizeof(char));
Console.WriteLine("The size of short is {0}", sizeof(short));
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 int is 4 The size of int is 2 The size of short is 2 The size of long is 8 The size of double is 8
热门推荐
1 如何训练狗狗不叫
2 训练狗狗不叫
3 训练狗狗随行
4 怎么训练狗狗不叫
7 训练比熊狗狗教程
10 上海狗狗训练
11 怎么训练狗狗上厕所
12 训练狗狗趴下
13 狗狗服从训练
14 训练狗狗拒食
15 训练狗狗笑
16 训练狗狗大便
17 训练狗狗立
18 训练狗狗捡东西