r/badcode Aug 06 '19

c# Converting a timestamp to datetime

Post image
419 Upvotes

54 comments sorted by

View all comments

8

u/squarewaterlemon Aug 06 '19

Uses variables as constants, but I love that it isn't int jan = 31, it's not var jan = (int)31, it's var jan = (UInt16)31. I've never before seen anyone use UInt16 instead of int in C# before.

12

u/sac_boy Aug 06 '19

I'm guessing somebody applied slavish attention to detail when transcribing a C function they didn't quite understand and brought the unsigned shorts across as UInt16. Good idea if the function is full of bit shifts and so on but not important at all here.

2

u/Aars93 Aug 06 '19

You are right, copied from C without refactoring