第2章 C#语法基础

第1-2课时 C#语法基础1随堂测试

1、单选题:
‎4、哪个是正确的变量名?‎
选项:
A: class
B: int
C: @int
D: 8value
答案: 【 @int

2、多选题:
‎1、变量的三个特性​
选项:
A: 名称
B: 类型
C: 不确定性
D: 值
答案: 【 名称;
类型;

3、多选题:
‍3、哪些是正确的变量名?‏‍‏
选项:
A: value
B: bool
C: @test
D: _str
答案: 【 @test;
_str

4、多选题:
‏5、C#中变量类型可分为哪两类:‏‏‏
选项:
A: 值类型
B: 指针类型
C: 引用类型
D: 地址类型
答案: 【 值类型;
指针类型;
引用类型

5、多选题:
​6、在C#中,关键字bool是System.Boolean的别名,此bool关键字声明的变量可以存放的值有:‎​‎
选项:
A: 0
B: true
C: false
D: 1
答案: 【 true;
false

6、判断题:
‎2、常量的值可以在别的地方修改。‌
选项:
A: 正确
B: 错误
答案: 【 错误

7、填空题:
‎7、在C#中,可以“_______”运算符连接string字符串。‎‎‎
答案: 【 +

8、填空题:
‍8、在C#中,用“__________”运算符访问string中的每个字符;‏‍‏
答案: 【 []##%_YZPRLFH_%##方括号

9、填空题:
‏9、string strTemp=”abcdefg123”;‌int index=strTemp.IndexOf(“h”);请问Index的值是什么?‌‏‌
答案: 【 -1

10、填空题:
​10、string strTemp=”abcdefg123”;‍int index=strTemp.IndexOf(“a”);请问Index的值是什么?‍​‍
答案: 【 0

11、填空题:
‏11、string strTemp=”abcdefg123”;‏int length=strTemp.Length();请问length的值是什么?‏‏‏
答案: 【 10

12、填空题:
​12、 string value = "This is a short string.";​​char delimiter = 's';​string[] substrings = value.Split(delimiter);​substrings的长度是多少?​​​
答案: 【 5

13、填空题:
‎13、 string value = "This is a short string.";‎‎char delimiter = 's';‎string[] substrings = value.Split(delimiter);‎substrings里存放的内容是什么?‎‎‎
答案: 【 Thi##%_YZPRLFH_%##i##%_YZPRLFH_%##a##%_YZPRLFH_%##hort##%_YZPRLFH_%##tring.

14、填空题:
14、short _short = 10;‎    int _int=30;‎_short=_int;‎会出什么问题?‎
答案: 【 编译不了##%_YZPRLFH_%##编译通不过

15、填空题:
‍15、int i = 20;​    object obj = i;  //装箱​    int j = (____________)obj;  //拆箱​‍​
答案: 【 int

16、填空题:
‏16、C#中的在枚举名第一个字母____________________________(大写或小写)。‎‏‎
答案: 【 大写

17、填空题:
‎17、枚举类型属在默认的情况下序列号从_________________开始。‎
答案: 【 0

18、填空题:
‌18、数组的属性_______________用于计算数组中存储的数据的实际个数。‍‌‍
答案: 【 Length

19、填空题:
‏19、int s;float x=0.5f;   s = x != 0.0 ?x : 1.0; ​‏请问:s值是__________________。​
答案: 【 0.5

20、填空题:
‍20、请写出程序运行的结果。​‍bool a = true;​‍int b = 30;​‍bool result=a&(b>50?true :false);​‍result = !result;​‍Console.WriteLine(result);​‍​
答案: 【 True##%_YZPRLFH_%##true

21、填空题:
‍21、请写出程序运行的结果。‍‍string str = "abcdefg";‍‍str = str + "1234567";‍‍string result;‍‍result= str.Substring(5,6);‍‍Console.WriteLine(result); ‍‍‍
答案: 【 fg1234

22、填空题:
‎22、‌‎请写出程序运行的结果。‌‎int a = 20;‌‎int b = 50;‌‎string result;‌‎result = a < b ? "a<b" : "a>b";‌‎Console.WriteLine(result);‌
答案: 【 a<b

23、填空题:
​23、请写出程序运行的结果。‏​int num=20;‏​bool result;‏​result=num<30;‏​‏
答案: 【 False##%_YZPRLFH_%##false

24、填空题:
‎24、请写出程序运行的结果。​‎int  num=20;​‎string  str;​‎string  result;​‎str=num>30?"大" :"小";​‎result ="结果是:"+str;​‎Console.WriteLine(result);​‎​
答案: 【 结果是:小##%_YZPRLFH_%##结果是:小

25、填空题:
‍25、请写出程序运行的结果。‏‍string str = "123";‏‍str = str + "abcd";‏‍string result;‏‍result= str.Substring(2,4);‏‍Console.WriteLine(result); ‏‍‏
答案: 【 3abc

26、填空题:
‏26、请写出程序运行的结果。‍‏int x=20; ‍‏int y=30; ‍‏int result;‍‏result=x+ y;‍‏Console.WriteLine(result);‍‏‍
答案: 【 50

27、填空题:
‍27、请写出程序运行的结果。‎‍string str = "abc";&lrm

剩余75%内容付费后可查看

发表评论

电子邮件地址不会被公开。 必填项已用*标注