How are switch cases new?

It surprised me when you said “We are going to use this cool new thing as of C# 7” and then you busted out a switch case. I work with those in old-school C all the time. Can you elaborate on what you mean by “new”?

Switch is not new, switch on the Type is new.
Previously you could only switch on things like int’s, string’s, enum’s and you could add a case for different values. You could not do a switch and on case check the type.

The technical term is Pattern Matching C# 7 Switch Pattern Matching - Codebuns

2 Likes

Thanks for the insight and thank you for teaching this course. I’ve learned so much from this course, not only about game development, but also things I can apply to my job. You’re a legend!

Privacy & Terms