Open ktaylor90 opened 4 months ago
I think that's a fair point. The main thing with this is just that the left hand side must be a compile-time constant. So an int
constant like 1
works, as does a string constant like "something"
. It is probably fair to say that the book should call this out more clearly and/or show an example with something besides just int
values.
noticed your solution shows a version of the switch expression not covered in the book. the first instance was covered but had no idea you could do the reverse of 1=> "something" as "something" =>1.
I've seen something similar in a lower chapter using the Console.ReadLine method contained within the Convert.ToInt32 method. It wasn't covered in the book as an option to do but was something one of your solutions included. I've run across this type of thing with other C# learning tools, where a solution included code syntax not covered in the topic, which makes it somewhat hard for someone completely new.