Skip to content

Introduce TryConvertToNumber methods for safe word-to-number conversion #1582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

omier-hasoun
Copy link

@omier-hasoun omier-hasoun commented Jun 26, 2025

Summary

This PR adds two new overloads of TryConvert to the WordsToNumber API:

  • bool TryConvertTNumber(string input, out int result)
  • bool TryConvertToNumber(string input, out int result, out string? unrecognizedWord)

These additions improve the API by offering exception-free number parsing, allowing for safer conversions and better user experience when dealing with potentially malformed input.

Related Issue

Fixes #<#1571>

Checklist

  • Clean implementation
  • Adheres to existing coding standards
  • No Code Analysis warnings
  • Unit tests added and pass
  • No external code (not copied from blogs or StackOverflow)
  • Minimal or no comments (clean code)
  • XML docs added to public methods
  • Rebased on latest main
  • All tests pass using build.ps1
  • No README changes needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant