You use an enumeration (or an enum) to define a restricted set of valu การแปล - You use an enumeration (or an enum) to define a restricted set of valu ไทย วิธีการพูด

You use an enumeration (or an enum)

You use an enumeration (or an enum) to define a restricted set of values.
Enums make your code clearer because you can use descriptive names
instead of something abstract like an integer value.
If you wanted to define an enumeration to describe a machine state, you
could do something like Listing 19-1.
Listing 19-1. Defining Enumerations
enum State {
case Inactive
case Active
case Hibernate
case Terminated
}
var machineState = State.Inactive
In Listing 19-1, you defined an enum named State that can have four values:
Inactive, Active, Hibernate, and Terminated. You specify enum values with
the case keyword. You can specify one value per case keyword, or you can
provide a comma-separated list of enum values on one line.
You can use enumeration types like other types. In Listing 19-1, you are
assigning the value State.Inactive to the variable machineState.
You can also reference the enum type in the ternary conditional operator
(Chapter 16), if statements (Chapter 23), switch statements (Chapter 24),
and anywhere else variables or constants are used.
Listing 19-2 shows an example of how you would use the State enum with
the ternary conditional operator.
0/5000
จาก: -
เป็น: -
ผลลัพธ์ (ไทย) 1: [สำเนา]
คัดลอก!
You use an enumeration (or an enum) to define a restricted set of values.
Enums make your code clearer because you can use descriptive names
instead of something abstract like an integer value.
If you wanted to define an enumeration to describe a machine state, you
could do something like Listing 19-1.
Listing 19-1. Defining Enumerations
enum State {
case Inactive
case Active
case Hibernate
case Terminated
}
var machineState = State.Inactive
In Listing 19-1, you defined an enum named State that can have four values:
Inactive, Active, Hibernate, and Terminated. You specify enum values with
the case keyword. You can specify one value per case keyword, or you can
provide a comma-separated list of enum values on one line.
You can use enumeration types like other types. In Listing 19-1, you are
assigning the value State.Inactive to the variable machineState.
You can also reference the enum type in the ternary conditional operator
(Chapter 16), if statements (Chapter 23), switch statements (Chapter 24),
and anywhere else variables or constants are used.
Listing 19-2 shows an example of how you would use the State enum with
the ternary conditional operator.
การแปล กรุณารอสักครู่..
ผลลัพธ์ (ไทย) 2:[สำเนา]
คัดลอก!
คุณสามารถใช้การแจงนับ (หรือ enum) เพื่อกำหนดชุด จำกัด ของค่า.
Enums ทำให้รหัสของคุณชัดเจนเพราะคุณสามารถใช้ชื่อพรรณนา
แทนสิ่งที่เป็นนามธรรมเช่นค่าจำนวนเต็ม.
ถ้าคุณต้องการที่จะกำหนดแจงนับในการอธิบายรัฐเครื่อง คุณ
สามารถทำสิ่งที่ชอบ Listing 19-1.
Listing 19-1 กำหนด Enumerations
enum รัฐ {
กรณีที่ไม่ได้ใช้งาน
ในกรณีที่ใช้งาน
กรณี Hibernate
กรณีสิ้นสุด
}
var machineState = State.Inactive
ในรายการ 19-1, คุณกำหนดไว้ enum ชื่อรัฐนั้นสามารถมีสี่ค่า:
ไม่ได้ใช้งานที่ใช้งาน, ไฮเบอร์เนตและสิ้นสุด คุณสามารถระบุค่า enum กับ
คำหลักกรณี คุณสามารถระบุค่าต่อหนึ่งคำหลักกรณีหรือคุณสามารถ
ให้รายการคั่นด้วยเครื่องหมายจุลภาคของค่า enum ในหนึ่งบรรทัด.
คุณสามารถใช้การนับประเภทเช่นประเภทอื่น ๆ ในรายการ 19-1 คุณจะได้รับ
การกำหนดค่า State.Inactive เพื่อ machineState ตัวแปร.
นอกจากนี้คุณยังสามารถอ้างอิงชนิด enum ในผู้ประกอบการที่มีเงื่อนไข ternary
(บทที่ 16) ถ้างบ (บทที่ 23) สลับงบ (บทที่ 24)
และอื่น ๆ ตัวแปรหรือค่าคงที่จะใช้.
ชื่อ 19-2 แสดงให้เห็นตัวอย่างของวิธีการที่คุณจะใช้ enum รัฐกับ
ผู้ประกอบการที่มีเงื่อนไข ternary
การแปล กรุณารอสักครู่..
ผลลัพธ์ (ไทย) 3:[สำเนา]
คัดลอก!
คุณใช้ใช้ ( หรือนัม ) เพื่อกำหนด จำกัด ชุดของค่า
enums ทำให้รหัสของคุณที่ชัดเจนเพราะคุณสามารถใช้ชื่อที่อธิบาย
แทนอะไรที่เป็นนามธรรมเช่นจำนวนเต็มค่า .
ถ้าคุณต้องการกำหนดมีการอธิบายสภาพเครื่อง คุณสามารถทำสิ่งที่ชอบรายการ 19-1
.
รายการ 19-1 . การกำหนดเครื่องนัม {

สภาพกรณีใช้งาน


กรณีคดีจำศีลกรณียกเลิก
}

machinestate var = รัฐ ไม่มีในรายการ 19-1 คุณกำหนดเป็นนัมชื่อรัฐที่สามารถมี 4 ค่า :
งาน , ปราดเปรียว , ไฮเบอร์เนตและสิ้นสุดลง คุณสามารถระบุค่านัม
กรณีคำหลัก คุณสามารถระบุค่าหนึ่งต่อคดีหลัก หรือคุณสามารถ
ให้คั่นด้วยเครื่องหมายจุลภาครายชื่อนัมค่าในบรรทัดเดียว คุณสามารถใช้ประเภทการ
เหมือนชนิดอื่น ๆ ใน 19-1 รายการ ,คุณ
การกําหนดค่าสถานะ ไม่แปร machinestate .
คุณสามารถอ้างอิงประเภทนัมในพ.ศ.
) เงื่อนไข ( บทที่ 16 ) ถ้างบ ( บทที่ 23 ) เปลี่ยนข้อความ ( ตอนที่ 24 ) และตัวแปรหรือค่าคงที่ไหน

รายการใช้ 19-2 แสดงตัวอย่างของ วิธีการที่คุณจะใช้รัฐนัมกับ
ผู้ประกอบการมีเงื่อนไขประกอบไปด้วย .
การแปล กรุณารอสักครู่..
 
ภาษาอื่น ๆ
การสนับสนุนเครื่องมือแปลภาษา: กรีก, กันนาดา, กาลิเชียน, คลิงออน, คอร์สิกา, คาซัค, คาตาลัน, คินยารวันดา, คีร์กิซ, คุชราต, จอร์เจีย, จีน, จีนดั้งเดิม, ชวา, ชิเชวา, ซามัว, ซีบัวโน, ซุนดา, ซูลู, ญี่ปุ่น, ดัตช์, ตรวจหาภาษา, ตุรกี, ทมิฬ, ทาจิก, ทาทาร์, นอร์เวย์, บอสเนีย, บัลแกเรีย, บาสก์, ปัญจาป, ฝรั่งเศส, พาชตู, ฟริเชียน, ฟินแลนด์, ฟิลิปปินส์, ภาษาอินโดนีเซี, มองโกเลีย, มัลทีส, มาซีโดเนีย, มาราฐี, มาลากาซี, มาลายาลัม, มาเลย์, ม้ง, ยิดดิช, ยูเครน, รัสเซีย, ละติน, ลักเซมเบิร์ก, ลัตเวีย, ลาว, ลิทัวเนีย, สวาฮิลี, สวีเดน, สิงหล, สินธี, สเปน, สโลวัก, สโลวีเนีย, อังกฤษ, อัมฮาริก, อาร์เซอร์ไบจัน, อาร์เมเนีย, อาหรับ, อิกโบ, อิตาลี, อุยกูร์, อุสเบกิสถาน, อูรดู, ฮังการี, ฮัวซา, ฮาวาย, ฮินดี, ฮีบรู, เกลิกสกอต, เกาหลี, เขมร, เคิร์ด, เช็ก, เซอร์เบียน, เซโซโท, เดนมาร์ก, เตลูกู, เติร์กเมน, เนปาล, เบงกอล, เบลารุส, เปอร์เซีย, เมารี, เมียนมา (พม่า), เยอรมัน, เวลส์, เวียดนาม, เอสเปอแรนโต, เอสโทเนีย, เฮติครีโอล, แอฟริกา, แอลเบเนีย, โคซา, โครเอเชีย, โชนา, โซมาลี, โปรตุเกส, โปแลนด์, โยรูบา, โรมาเนีย, โอเดีย (โอริยา), ไทย, ไอซ์แลนด์, ไอร์แลนด์, การแปลภาษา.

Copyright ©2025 I Love Translation. All reserved.

E-mail: