This is something that comes up a lot in end games (sometimes earlier) and I’m not sure how to judge what’s best.
In this situation, W plays D19, black answers with C19, white plays E19, and now black needs to protect against further invasion.
This would be either C18 or C17, in this case – does it matter which? If so, why? What broader situations might make one better than the other… or does it generally not matter at all?
C18. nothing fancy needed.
anything else risks a ko in the future.
B18 would also be perfectly acceptable in most cases. Usually the question comes down to eye shape and / or end game efficiency. The differences are subtle.
If you’re not at least SDK (and even then), you probably have very little to be concerned about. As long as you’re playing one of them
In general, the solid connection (c18) is better than hanging connection (b18) because it doesn’t leave the same ko threats on the board.
B18 is better at creating eyeshape, so it can better if your group isn’t guarantee to have 2 eyes with the solid connection. But if you know that your group is well alive even without making extra eyespace, there isn’t usually any good reason for allowing white to have those ko threats at c18 and b19
C17 is a bit “funny” shape, but it works in that pic as well. Note that it alse leaves ko threat behind (peep at b18 or the atari at b19), so ~only situation where c17 is stronger than c18 is if you want to block the corner from the direction of c15 stones. It might make sense if c15/d15 stones would have been white here, but since they are black there isn’t any good reason for it.
So yes, all of b18, c18, and c17 would work here, the subtle difference is mostly ko threats left behind since that black group is alive.
The main point where all of this changes is when the hane is on the second line not the first line. In this case the hanging connection makes blocking the later first line move sente not gote.
Just to add to @BHydden and @_KoBa’s answers: another interesting property of B18 is that it helps protect the other side too. Picture later in the game W A15, B A16, W A14, then black doesn’t need to protect the cut at B16 because B18 already does.
Be careful with that though as it doesn’t always work. I would recommend doing some problems to familiarize yourself with the position.
Loosely related … good enough excuse for a meme-link!
Not the best examples but you’ll get the gist (if safely alive, play solidly, otherwise play tiger’s mouth):