With a digital model railway, train detection (block signaling) is an important function. Most often current sensing is used. It is quite reliable and you don’t have any (possibly ugly and always non-prototypical) sensors in view. The drawback is that it probably also is the most expensive method.
I like to try out some different sensing methods. Just for fun … and also because I like to use the Arduino for S88 sensor feedback, which can reduce cost by a factor of 5 or more!
This video covers the use of a reed switch and a magnet glued under the loc.
Optical detection has been discussed earlier, see this blog post.