If using fresh corn, remove the husks and silk, then carefully cut the kernels from the cobs. If using frozen corn, thaw and drain it if possible.
Melt the butter in a large skillet or saucepan over medium heat.
Add the corn kernels and cook for 3 to 5 minutes, stirring occasionally, until the corn is heated through. If using garlic powder or onion powder, add it at this stage.
Sprinkle the flour over the corn and stir until the kernels are evenly coated. Cook for 1 minute, stirring constantly.
Slowly pour in the milk and heavy cream while whisking or stirring continuously to prevent lumps.
Add the sugar, salt, and black pepper. Stir well to combine.
Reduce the heat to low and simmer for 5 to 8 minutes, stirring frequently, until the sauce thickens and becomes creamy.
Stir in the Parmesan cheese, if using, and cook for another 1 to 2 minutes until melted.
Taste and adjust the salt, pepper, or sugar as needed.
Garnish with chopped chives or parsley and serve warm.