r/badcode • • Dec 20 '20

c# Was looking through my code and found this.

Post image
697 Upvotes

86 comments sorted by

View all comments

17

u/thatwasagoodyear Dec 20 '20

Also, Convert.ToBoolean is already built in with overload support for different input types & formats.

If you're doing tons of conversions and concerned about having Convert. littering your code, add a using static System.Convert; to your using statements to import all of the static methods of the type so that you can call them as if they were a static function local to your type, e.g. ToBoolean(input), ToUInt64(input), FromBase64String(input), etc.