IssueRaiser

That doesn't work for a standard library - it may make you happy, but the next developer may have very different needs.

That doesn't work for a standard library - it may make you happy, but the next developer may have very different needs. Int32.TryParse() does not distinguish between null and empty strings and it takes only a minute or two to create an extension method and the problem is solved once and forever. public static class StringExtensions { public static Int32? ParseAsNullableInt32(this String self, Int32? fallback = null) { Int32 result; return Int32.TryParse(self, out result) ? result : fallback; } }

Posted by danbruc on Nov 3, 2014, 5:06 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.9,000 issues0 comments

hackernews (Other)

That doesn't work for a standard library - it may make you happy, but the next developer may have very different needs.

danbrucNov 3, 2014, 5:06 PM

That doesn't work for a standard library - it may make you happy, but the next developer may have very different needs. Int32.TryParse() does not distinguish between null and empty strings and it takes only a minute or two to create an extension method and the problem is solved once and forever. public static class StringExtensions { public static Int32? ParseAsNullableInt32(this String self, Int32? fallback = null) { Int32 result; return Int32.TryParse(self, out result) ? result : fallback; } }

Comments (0)

No comments yet. Start the discussion.

Comment on this issue