c# truthy and falsy values

C# only has literal true and false values.

C# requires you to be very explicit in your declarations. This behaves like other popular strongly-typed languages, as opposed to JavaScript which can do implicit conversions when needed.

It should be noted for clarity that “strong typing” is not the reason why C# doesn’t implicitly convert to “truthy/falsy” values. The language intentionally is trying to avoid the pitfalls of some other compiled languages like C where certain values can be truthy, like ‘0‘ or ‘1‘ which could allow you to make a syntactical mistake you might not notice until runtime when your code behaves unexpectedly.

Leave a Comment