I recently switched from VB to C #. One thing I noticed is that in C # I have problems using comparisons as part of the case. I'm not sure how to explain it in words, so here is an example of what I'm trying to do.
In VB, my code looks and works just fine.
Select Case ExamScore Case Is >= 90 Grade = "A" Case Is >= 80 Grade = "B" Case Is >= 70 Grade = "C" Case Is >= 60 Grade = "D" Case Else Grade = "F" End Select
In C #, on the other hand, Visual Studio tells me that "> =" is an invalid expression.
switch (examScore) { case >= 90: grade = "A"; break; case >= 80: grade = "B"; break; case >= 70: grade = "C"; break; case >= 60; grade = "D"; break; default: grade = "F"; break; }
Am I doing something wrong here, or is it just impossible to do in C #?
Thank you in advance!
user2763890
source share