Make the "out" modifier when calling a method optional if the result is being discarded #2778
-
In this function: public static bool IsBoolean(string s)
{
return bool.TryParse(s, out _);
} the public static bool IsBoolean(string s)
{
return bool.TryParse(s, _);
} or maybe even public static bool IsBoolean(string s)
{
return bool.TryParse(s);
} |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
This would make it a breaking change then for |
Beta Was this translation helpful? Give feedback.
-
Whilst @CyrusNajmabadi is right that the second example would cause problems, I think there is merit in the other version: public static bool IsBoolean(string s)
{
return bool.TryParse(s, _);
} The need for an |
Beta Was this translation helpful? Give feedback.
-
Building method resolution based on whether a parameter is used down the line or not... I really don't think this is a good idea to being with. |
Beta Was this translation helpful? Give feedback.
-
You make a good point. Sadly, the team didn't make using So this is a nice idea that likely won't happen. |
Beta Was this translation helpful? Give feedback.
This would make it a breaking change then for
bool
to add aTryParse
function that didn't have an out param in the future.