如何切换多个变量 [英] How to switch with multiple variables
本文介绍了如何切换多个变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个"非常基本"的理解switch(我在VB中编写代码并尝试学习C#)但我似乎无法弄清楚如何在C#中编写以下VB代码:
I have a "VERY BASIC" understanding of switch (I write code in VB and am attempting to learn C#) but I can't seem to figure out how to write the following VB code in C#:
Function GetFuelsINDUSTRY(ByVal cTypx As String, ByVal cLoad As String)
Select Case cTypx
Case "Shortleaf Pine with Oak"
Select Case cLoad
Case Is = "Low"
Return "3.0"
Case Is = "Moderate"
Return "4.0"
Case Is = "Heavy"
Return "4.4"
Case Else
Return False
End Select
Case "Shortleaf Pine Regeneration"
Select Case cLoad
Case Is = "Low"
Return "2.6"
Case Is = "Moderate"
Return "3.8"
Case Is = "Heavy"
Return "5.1"
Case Else
Return False
End Select
Case "Loblolly Pine with Oak"
Select Case cLoad
Case Is = "Low"
Return "6.4"
Case Is = "Moderate"
Return "6.8"
Case Is = "Heavy"
Return "7.9"
Case Else
Return False
End Select
Case "Loblolly Pine Regeneration"
Select Case cLoad
Case Is = "Low"
Return "4.4"
Case Is = "Moderate"
Return "7.6"
Case Is = "Heavy"
Return "8.5"
Case Else
Return False
End Select
Case "Hardwood Leaf Litter"
Select Case cLoad
Case Is = "Low"
Return "0.8"
Case Is = "Moderate"
Return "1.5"
Case Is = "Heavy"
Return "2.5"
Case Else
Return False
End Select
Case "Grass or Brush"
Select Case cLoad
Case Is = "Low"
Return "2.0"
Case Is = "Moderate"
Return "3.0"
Case Is = "Heavy"
Return "5.0"
Case Else
Return False
End Select
Case "Dispersed Slash"
Select Case cLoad
Case Is = "Low"
Return "4.0"
Case Is = "Moderate"
Return "6.0"
Case Is = "Heavy"
Return "8.0"
Case Else
Return False
End Select
Case "Piled Debris"
Select Case cLoad
Case Is = "Low"
Return "5.0"
Case Is = "Moderate"
Return "7.5"
Case Is = "Heavy"
Return "10.0"
Case Else
Return False
End Select
Case "Shortleaf Loblolly with Grass"
Select Case cLoad
Case Is = "Low"
Return "1.5"
Case Is = "Moderate"
Return "3.8"
Case Is = "Heavy"
Return "5.9"
Case Else
Return False
End Select
Case Else
Return False
End Select
End Function
我试过:
string ctype = cbox.selectedtext;
string cload = cbox2.selectedtext;
switch (ctype)
{
case "Shortleaf Pine with Oak":
{
switch (cload)
{
case "Low":
return 3.0;
case "Moderate":
return 4.0;
case "Heavy":
return 4.4;
}
etc...
有一天我会成为传奇,就在今天。
I will be legendary someday, just not today.
推荐答案
你不明白什么?如果您能够具体了解您不理解的内容,那将会非常有帮助。如果你提到你不理解的交换机文档的特定部分,那么你肯定会得到答案。
What don't you understand? It will really help if you can be specific about what you don't understand. If you refer to a specific part of the switch documentation that you don't understand then you will certainly get answers.
这篇关于如何切换多个变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文