Select Case True
Case Not A.Name Is Nothing
Set Name = A.Name
Case Not A.Age Is Nothing
Set Age = A.Age
Case Not A.School Is Nothing
Set School = A.School
End Select
In VB Select Case True is allowed to use. But for C# it gives an error. How can I convert this VB code to C# ?
There is no direct analog in C# because C# case labels must be constant expressions.
Select Case Trueis an unusual construct that serves as an alternative toif-elseconstructs.I suggest replacing it with the far more common pattern: