日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > C# >内容正文

C#

c#枚举数字转枚举_C#枚举能力问题和解答 套装4

發(fā)布時(shí)間:2023/12/1 C# 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c#枚举数字转枚举_C#枚举能力问题和解答 套装4 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

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

  • Answer & Explanation

    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

  • Answer & Explanation

    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

  • Answer & Explanation

    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

  • Answer & Explanation

    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

  • Answer & Explanation

    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)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。