Get a cast with a waterproof coating and that's made of fiberglass. If you have a plaster and gauze cast, don't get it wet at all. If you plan on swimming, ask the doctor in advance for a waterproof cast.
Wade around and try to keep your cast out of the water. This would be more for people with upper body casts, such as on the arm. True, it's not exactly swimming, but at least you're getting wet.
Buy a cast protector at a website like Mobility Smart (see link in Resources). As in Step 1, it would help to know ahead of time that you want to go swimming. Most of the models are sold in Europe.
Find a plastic bag or any other waterproof material and tape it to your cast with waterproof tape. A garbage bag and duct tape would work for this method. It's not highly recommended, but if you tape it up well enough, you may just protect your cast. The downside is all that tape may be hard to remove and will start to smell after swimming for a while.
Stay out of the water. Casts can seem like a curse, but they're only there to help. By jeopardizing the security of the cast, you are putting yourself in danger of re-injuring your healing wound. Before you know it, you'll be in a cast again for much longer.