WD40 probably won't hurt any - and will leave a thin film of oil to protect from further corrosion. But to actually clean electronics and get something that has a bad contact working good again, like say potentiometers, buttons and similar electro-mechanical devices, you want a specialist contact-cleaner.
Now, WD40 - the company - do sell this,
link here. I'm sure similar products from other brands (CRC for instance) will do just as well.