The only time to buy corn is when it is in season. In the South it comes into season in early summer. In the North local corn isn't available until late July (although some of the new hybrids like Precocious come in earlier). Frozen corn is OK as an ingredient in a dish, but I just can't eat it straight. It just tastes like plastic to me.
The best corn comes from nearby. This is where the locavores have it right. Trucking it cross country in a hot truck can kill its flavor and sweetness. Like fruit, I think the best corn comes from the cooler northern climates, where the days are hot and the nights are cool. If you buy at a farm stand, select ears that are in the shade. If you buy from a supermarket, ask the produce manager what state it came from. Look him/her in the eye. Ask when it arrived.
Inspect the ears. Don't pick the biggest. Pick the midsized ears. The husk should be pale green and moist. The cut end of the stem should not be brown. The silky threads coming out of the top may be brown, that's not a problem, but black is. The silk under the husk should be blond and as delicate as a child's hairs. Pull back the husk a few inches and look at the kernels. Not just the top kernels, which tend to be undersized, but the kernels 1-2" down. Leave behind the ears with big gaps, uneven sized kernels, really big kernels, and really small kernels. Don't worry if there is a worm hole. You can cut it out. You're dealing with nature here. She ain't perfect.
Some kernels are white and some are yellow depending on the variety, and some varieties even have both white and yellow on the same ear. When nobody's looking, find a typical ear and with the nail of your thumb, puncture a kernel. The juice should be milky and taste sweet. If it is, find identical ears and load up. If it isn't, skip the corn and make potato salad.
When you get it home, leave it in the husk and get in into the fridge ASAP.
New corn varieties stay sweet longer
Once upon a time, the strategy was: Get the water boiling, run to the field, pick the corn, run back husking all the way, and throw the fresh corn into the hot water. That's because the natural sugars in corn start turning to starch shortly after it is harvested. But now there are new hybrids that stay sweet for 2-4 days. Called sugar enhanced and shrunken-2 varieties, they allow city dwellers to get corn as sweet as farm folk.
Now don't panic. These hybrids are not Frankenfood. In fact, sweet corn, called sugary, is a mutation from dent corn, a.k.a. field corn, that is used for animal feed, corn oil, and ethanol.
Perhaps the best known of the new varieties is Silver Queen, but there are many others whose names make the mouth water (those breeders must be transplants from Madison Avenue). Some farm stands list their names so here are a few: Bodacious, Calico Belle, Challenger, Crisp N'Sweet, Dazzle, Even Sweeter, Incredible, Landmark, Maple Sweet, Pinnacle, Platinum Lady, Snowbelle, Ssupersweet (yess there are two letterss ss), Summerflavor, Sweetie, Top Notch, Viva, and Zenith.