So I was looking up C# Caesar ciphers online and I found this website: https://www.programmingalgorithms.com/algorithm/caesar-cipher
I looked through and generally the code made sense to me until this part:
char offset = char.IsUpper(ch) ? 'A' : 'a';
return (char)((((ch + key) - offset) % 26) + offset);
I understand the ternary operator, it's mainly the second line that I can't make sense of, it returns a character,but somehow adds a character and a number together, subtracts a character, gets the modulus and then adds on a character?
The only explanation I've come up with is that each character has an ID and it's doing the operations on that rather than the character itself? Honestly it's a bit beyond me, if someone could explain it that would be great.
Thanks in advance.