C# Coding Standards – When Are Chained Assignments (a=b=c) Bad Form?

ccoding-standardscoding-stylenet

I'm working on a VB.Net WinForms project and found myself writing code like this:

this.Fizz.Enabled = this.Buzz.Enabled = someCondition;

I couldn't decide whether that was bad code or not. Are there any .NET guidelines for when/when-not to do assignment chaining?

Best Answer

I never do it. I always put each assignment on its own line. Clarity is king.

In practice, I seldom use enough state variables to make chaining assignments necessary. If I get to that point, I start looking for ways to trim the amount of state I am using.