r/badcode • • Aug 10 '19

c# absolute genius!

Post image
931 Upvotes

59 comments sorted by

View all comments

0

u/[deleted] Aug 10 '19

[deleted]

70

u/pierovera Aug 10 '19

I get this is shitty code, but this wouldn't even compile.

19

u/fond42518 Aug 10 '19

Can't even try compiling bc I'm on mobile rn. Is it because the redeclaration of k in the second method?

1

u/[deleted] Aug 10 '19 edited Aug 10 '19

I’m not sure but I thought in most languages you can only overload the constructor like that?

Edit: Sounds like I was right not to be sure

3

u/fond42518 Aug 10 '19

I'm assuming this code is Java, in which a class's methods can be overloaded as long as their input parameters are different.

Edit: nvm, just saw the C# flair

2

u/dbgprint Aug 10 '19

What languages can’t do this? C++ can do it too, as long as the function signature is different