c#枚举数字转枚举_C#枚举能力问题和解答 套装4
c#枚舉數(shù)字轉(zhuǎn)枚舉
1) What is the correct output of given code snippets in C#.NET? using System;class program {enum emp_salary : int{emp1 = 10000,emp2 = 15000,emp4 = 20000}static void Main(string[] args){int sal = (int)emp_salary.emp2;Console.WriteLine(sal);} }10000
15000
Syntax error
Runtime exception
Correct answer: 2
15000
The above code will print "15000" on console screen.
1)C#.NET中給定代碼段的正確輸出是什么?10000
15000
語法錯(cuò)誤
運(yùn)行時(shí)異常
正確答案:2
15000
上面的代碼將在控制臺(tái)屏幕上打印“ 15000” 。
2) What is the correct output of given code snippets in C#.NET? using System;class program {enum emp_salary : byte{emp1 = 10000,emp2 = 15000,emp4 = 20000}static void Main(string[] args){int sal = (int)emp_salary.emp2;Console.WriteLine(sal);} }10000
15000
Syntax error
Runtime exception
Correct answer: 3
Syntax error
The above code will generate syntax error because the value of enums is outside the range of byte.
2)C#.NET中給定代碼段的正確輸出是什么?10000
15000
語法錯(cuò)誤
運(yùn)行時(shí)異常
正確答案:3
語法錯(cuò)誤
上面的代碼將產(chǎn)生語法錯(cuò)誤,因?yàn)閑nums的值超出了字節(jié)范圍。
3) What is the correct output of given code snippets in C#.NET? using System;class program {enum emp_salary : float{emp1 = 10000,emp2 = 15000,emp4 = 20000}static void Main(string[] args){int sal = (int)emp_salary.emp2;Console.WriteLine(sal);} }10000
15000
Syntax error
Runtime exception
Correct answer: 3
Syntax error
The above code will generate syntax error because we cannot use a float with enum like this.
3)C#.NET中給定代碼段的正確輸出是什么?10000
15000
語法錯(cuò)誤
運(yùn)行時(shí)異常
正確答案:3
語法錯(cuò)誤
上面的代碼將產(chǎn)生語法錯(cuò)誤,因?yàn)槲覀儾荒芟襁@樣使用帶枚舉的浮點(diǎn)數(shù) 。
4) What is the correct output of given code snippets in C#.NET? using System;class program {enum emp_salary : int{emp1 = 10000,emp2 = 15000,emp4 = 20000}static void Main(string[] args){emp_salary sal = emp_salary.emp2;if (sal == emp_salary.emp2){Console.WriteLine("15000");}} }10000
15000
Syntax error
Runtime exception
Correct answer: 3
15000
The above code will print "15000" on the console screen.
4)C#.NET中給定代碼段的正確輸出是什么?10000
15000
語法錯(cuò)誤
運(yùn)行時(shí)異常
正確答案:3
15000
上面的代碼將在控制臺(tái)屏幕上打印“ 15000” 。
5) What is the correct output of given code snippets in C#.NET? using System;class program {int A = 10000;int B = 15000;int C = 20000;enum emp_salary : int{emp1 = A,emp2 = B,emp4 = C}static void Main(string[] args){emp_salary sal = emp_salary.emp2;if (sal == emp_salary.emp2){Console.WriteLine("15000");}} }10000
15000
Syntax error
Runtime exception
Correct answer: 3
Syntax error
The above code will generate a syntax error.
5)C#.NET中給定代碼段的正確輸出是什么?10000
15000
語法錯(cuò)誤
運(yùn)行時(shí)異常
正確答案:3
語法錯(cuò)誤
上面的代碼將生成語法錯(cuò)誤。
? C# Enumeration Aptitude | Set 3 C# Enumeration Aptitude | Set 5 ? #C#枚舉能力| 設(shè)置3 C#枚舉能力| 設(shè)置5?翻譯自: https://www.includehelp.com/dot-net/csharp-enumeration-aptitude-questions-and-answers-4.aspx
c#枚舉數(shù)字轉(zhuǎn)枚舉
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的c#枚举数字转枚举_C#枚举能力问题和解答 套装4的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 颐和园转一圈多长距离
- 下一篇: c# 前导0_C#| 用前导零填充整数