Quantum size effects in transport theory and diamagnetism