page contents

c# ushort_C#中的ushort关键字

本文讲述了c# ushort_C#中的ushort关键字!具有很好的参考价值,希望对大家有所帮助。一起跟随六星小编过来看看吧,具体如下:

attachments-2022-07-Ws48kUya62e1e9ea4cad9.png本文讲述了c# ushort_C#中的ushort关键字!具有很好的参考价值,希望对大家有所帮助。一起跟随六星小编过来看看吧,具体如下:

C#ushort关键字 (C# ushort keyword)

In C#, ushort is a keyword which is used to declare a variable that can store an unsigned integer value between the range of 0 to 65,535ushort keyword is an alias of System.UInt16.

在C#中, ushort是一个关键字,用于声明一个变量,该变量可以存储介于0到65,535之间的无符号整数值。 ushort关键字是System.UInt16的别名。

It occupies 2 bytes (16 bits) space in the memory.

它在内存中占用2个字节(16位)的空间。

Syntax:

句法:

ushort variable_name = value;

C#代码演示ushort关键字示例 (C# code to demonstrate example of ushort keyword)

Here, we are declaring an ushort variable num, initializing it with the value 12345 and printing its value, type and size of an ushort type variable.

在这里,我们宣布一个USHORT变量num,与价值12345初始化它和打印的USHORT类型变量它的价值,类型和大小。



  1. using System;
  2. using System.Text;
  3. namespace Test
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. //variable declaration
  10. ushort num = 12345;
  11. //printing value
  12. Console.WriteLine("num: " + num);
  13. //printing type of variable
  14. Console.WriteLine("Type of num: " + num.GetType());
  15. //printing size
  16. Console.WriteLine("Size of a ushort variable: " + sizeof(ushort));
  17. //printing minimum & maximum value of ushort
  18. Console.WriteLine("Min value of ushort: " + ushort.MinValue);
  19. Console.WriteLine("Max value of ushort: " + ushort.MaxValue);
  20. //hit ENTER to exit
  21. Console.ReadLine();
  22. }
  23. }
  24. }

Output

输出量



  1. num: 12345
  2. Type of num: System.UInt16
  3. Size of a ushort variable: 2
  4. Min value of ushort: 0
  5. Max value of ushort: 65535

更多相关技术内容咨询欢迎前往并持续关注六星社区了解详情。

想高效系统的学习Python编程语言,推荐大家关注一个微信公众号:Python编程学习圈。每天分享行业资讯、技术干货供大家阅读,关注即可免费领取整套Python入门到进阶的学习资料以及教程,感兴趣的小伙伴赶紧行动起来吧。

attachments-2022-05-rLS4AIF8628ee5f3b7e12.jpg

  • 发表于 2022-07-28 09:44
  • 阅读 ( 474 )
  • 分类:C/C++开发

你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
轩辕小不懂
轩辕小不懂

2403 篇文章

作家榜 »

  1. 轩辕小不懂 2403 文章
  2. 小柒 1312 文章
  3. Pack 1135 文章
  4. Nen 576 文章
  5. 王昭君 209 文章
  6. 文双 71 文章
  7. 小威 64 文章
  8. Cara 36 文章