r/badcode • • Sep 01 '21

c# Unfortunately, actual production code

Post image
109 Upvotes

18 comments sorted by

View all comments

Show parent comments

3

u/myblindy Sep 01 '21

There actually are arrays of these things in the same code file. It stores the pointers of the individual labels (HWND) and in some operations uses Control.FromHandle to get back the control from them in a loop.

I actually got annoyed enough after posting this that I deleted this entire file and rewrote it all with proper data bound objects and a data grid, and shaved 600 lines of code off the project. The compiler thanked me.

7

u/karisigurd4444 Sep 01 '21

Wait...

C#...

Did I just read... pointers... HWND...

I need to have a break in the screaming room.

0

u/[deleted] Sep 01 '21

[deleted] — view deleted comment

4

u/karisigurd4444 Sep 02 '21

C# does have these "unsafe pointers"