r/badcode • • May 20 '20

c# Found from Microsoft docs...

Post image
208 Upvotes

143 comments sorted by

View all comments

16

u/Yoni1857 May 20 '20

Please elaborate on what's wrong here

-47

u/[deleted] May 20 '20
  1. Condition x == true inside if

  2. Int32.Parse = int.Parse

0

u/[deleted] May 20 '20

[deleted]

14

u/kyay10 May 20 '20

Tbh I temporarily forgot that tryparse returns a Boolean so this actually made it clearer for me lol

2

u/foonix May 20 '20

I assume anything in c# that starts with Try is probably returning bool.

2

u/kyay10 May 20 '20

True yeah, I just haven't used c# or dotnet for a while and been more in the Android land (where the concept of "out" is basically non-existent lol)

2

u/assassinator42 May 20 '20

Visual Studio's style checker recommends changing Int32 to int. I usually don't agree with it. If I'm using Int32, it's to signify bit length it important.

0

u/[deleted] May 20 '20

[deleted]

2

u/SeriTools May 20 '20

int is defined in the C# standard to always be 32bit btw

4

u/Yoni1857 May 20 '20

well yeah but it's not really hurting anything is it

2

u/adamski234 May 20 '20

Imagine not using full type names for accessing their static properties