Alex Rivera | Logout

Why doesn't C# support local static variables like C does?

Asked 2009-06-26T15:16:10.050
95

Why doesn't C# have local static variables like C? I miss that!!

Edit
Report

1 Answer

186

Because they screwed up, and left out a useful feature to suit themselves.

All the arguments about how you should code, and what's smart, and you should reconsider your way of life, are pompous defensive excuses.

Sure, C# is pure, and whatchamacallit-oriented. That's why they auto-generate persistent locals for lambda functions. It's all so complicated. I feel so dumb.

Loop scope static is useful and important in many cases.

Short, real answer, is you have to move local statics into class scope and live with class namespace pollution in C#. Take your complaint to city hall.

answered 2010-04-11T11:57:38.837

Your Answer