Classically, if we have a magnetic field that is confined to a region of space and a charged particle moves outside that region, the particle cannot feel any effect of the field. In quantum mechanics the situation changes as a particle encircling a solenoid gathers a phase shift dependent on the magnetic flux enclosed by its trajectory, despite moving in region where the magnetic field vanishes. This phenomenon is called the Aharonov--Bohm effect. We investigate the number of zero modes (i.e. the degeneracy of the zero eigenvalue) of the Dirac operator describing a charged particle with spin confined to a plane with holes that contain such Aharonov--Bohm solenoids. For the domain of the Dirac operator we consider the global Atiyah--Patodi--Singer (APS) boundary condition which was introduced in the 70s by APS in connection with the index theorem on manifolds with boundary. We find that the number of zero modes depends only on the flux of the magnetic field. The result is a generalisation of the Aharonov–Casher theorem. The talk is based on my PhD project adviced by Jan Philip Solovej.