If/else VS switchCase

What the major use case difference is between if/else and switchCase.

Currently I'm using this:

if (digitalRead(5) == HIGH) 
               {client.println("ON");}

if (digitalRead(5) == LOW) 
               {client.println("OFF");}

Could I replace it with this:

Switch (digitalRead(5)) {

Case 0:{

  client.println("OFF");
}
  break;

Case 1:{

  client.println("ON");
}
  break;

Why not

client.println(digitalRead(5)? "ON" : "OFF");

Thanks,
I can't find anything in the reference that explains how the : is used. But am I right in saying that your post above is essentially saying.

"Check if digitalRead(5) is on or off, and then print the result"

?

For only two alternatives I would prefer the if-version, the ternary-version is ok too.
Your switch syntax is faulty and contains superfluous brackets.

if (digitalRead(5)) {
  client.println(F("ON"));
} else {
  client.println(F("OFF"));
}
switch (digitalRead(5)) {
case LOW:
  client.println(F("OFF"));
  break;
case HIGH:
  client.println(F("ON"));
}

Whandall:
For only two alternatives I would prefer the if-version, the ternary-version is ok too.
Your switch syntax is faulty and contains superfluous brackets.

if (digitalRead(5)) {

client.println(F("ON"));
} else {
  client.println(F("OFF"));
}

switch (digitalRead(5)) {
case LOW:
  client.println(F("OFF"));
  break;
case HIGH:
  client.println(F("ON"));
}

Interesting, getting it wrong helps me understand how it comes together a bit better at least.

Why would you use the (F()) macro?

denski:
Why would you use the (F()) macro?

Why would you like the string constants in RAM?

Whandall:
Why would you like the string constants in RAM?

I'm a total novice, so I'm trying to understand it's use in general.
Re-reading the reference tells me to assume that you put it in flash memory so as not to waste valuable RAM. As ON or OFF is a constant it doesn't need to be processed, so it can live in Flash.

Would that be correct?

Yes.

Without the F() the constants would be copied to RAM and there is very little of that in normal Arduinos.

Whandall:
Yes.

Cheers!