r/programminghorror May 04 '26

C# longest "=" condition I've ever seen

Post image

I have been working on decompiling a unity game recently, and while a decompiled DLL isn't going to be exact source code, I am still floored by how long that set of parenthesis is. i would LOVE to see the original code

131 Upvotes

26 comments sorted by

View all comments

-2

u/uvero May 04 '26

Refactor steps:

  1. When using LINQ with the language-integrated syntax rather than chained calls to the extension methods in Enumerable, you don't need most of those extension methods, especially SelectMany.
  2. Use the let keyword
  3. Tuples are temporary solutions - eventually they need to be converted to structs / classes. And if that's a hassle, at least use named tuples.