第3章:变量、数据类型和表达式内容摘要:

char byte sbyte或 char short sbyte、 byte、 ushort、 uint、 ulong或 char ushort sbyte、 byte、 short或 char int sbyte、 byte、 short、 ushort、 uint、 ulong或 char uint sbyte、 byte、 short、 ushort、 int或 char long sbyte、 byte、 short、 ushort、 int、 uint、 ulong或 char ulong sbyte、 byte、 short、 ushort、 int、 uint、 long或 char char sbyte、 byte或 short float sbyte、 byte、 short、 ushort、 int、 uint、 long、 ulong、 char或 decimal double sbyte、 byte、 short、 ushort、 int、 uint、 long、 ulong、 char、 float或 decimal decimal sbyte、 byte、 short、 ushort、 int、 uint、 long、 ulong、 char、 float或 double 示例代码 从 sbyte、 byte、 short、 ushort、 int、 uint、 long、ulong、 char、 float、 double或 decimal转换为任何枚举类型 从任何枚举类型转换为 sbyte、 byte、 short、ushort、 int、 uint、 long、 ulong、 char、 float、double或 decimal 从任何枚举类型转换为任何其他枚举类型 显式枚举转换 显式枚举转换包括以下内容: 多媒体演示:显式枚举转换 多媒体演示 示例代码 随堂练习 随堂练习 1. 下面声明了一些数值类型的变量 short s=10。 int i=5。 uint ui=50。 long l=1000。 double d=。 decimal m = 154。 2. 试着分析下列哪些类型转换是正确的: s = ui。 i = ui。 s = l。 l = s。 m = d。 d = m。 l = d。 m = i。 随堂练习 (续) 随堂练习 3. 试着写出以下这段程序的运行结果: using System。 using。 using。 namespace convert { enum Color{ Red,Yellow,Blue,Green,Purple,Black,White }。 class Program { static void Main(string[] args) { Color [] color_arr=new Color [3]。 int[] int_arr = new int[]{1,2,3}。 color_arr[0] = (Color)int_arr[0]。 color_arr[1] = (Color)int_arr[1]。 color_arr[2] = (Color)int_arr[2]。 (The value of color_arr[0] is :{0}, color_arr[0])。 (The value of color_arr[1] is :{0}, color_arr[1])。 (The value of color_arr[2] is :{0}, color_arr[2])。 } } } 变量 常量 C 数据类型 类型转换 运算符和表达式 小结 实验 习题 第 3章 变量、数据类型 和表达式 运算符类型 运算符的优先级 简单的赋值运算符与赋值表达式 算术运算符与算术表达式 关系运算。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。