FluentParsing 1.0.0

dotnet add package FluentParsing --version 1.0.0
                    
NuGet\Install-Package FluentParsing -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FluentParsing" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FluentParsing" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="FluentParsing" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FluentParsing --version 1.0.0
                    
#r "nuget: FluentParsing, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FluentParsing@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FluentParsing&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=FluentParsing&version=1.0.0
                    
Install as a Cake Tool

FluentParsing

FluentParsing is a lightweight .NET extension library that simplifies converting string values into primitive types with fluent syntax and optional error handling. Designed for developers who want cleaner, more expressive code when dealing with string parsing.


Features

  • Extension methods for parsing string to:
    • int
    • long
    • float
    • double
    • decimal
    • char
  • Optional exception throwing for invalid input
  • Fluent, readable syntax for safer conversions

Installation

Install via NuGet Package Manager:

dotnet add package FluentParsing

Or via the NuGet UI in Visual Studio.


Usage

Import the namespace:

using FluentParsing;

Basic Parsing

string input = "42";
int value = input.ToInt(); // returns 42

Graceful Failure

string input = "not-a-number";
int value = input.ToInt(); // returns 0 (default int)

Throw on Failure

string input = "oops";
int value = input.ToInt(shouldThrow: true); // throws ArgumentException

Supported Types

Method Return Type Default on Failure Throws Exception
ToInt() int 0 if shouldThrow = true
ToLong() long 0L if shouldThrow = true
ToFloat() float 0f if shouldThrow = true
ToDouble() double 0d if shouldThrow = true
ToDecimal() decimal 0m if shouldThrow = true
ToChar() char '\0' if shouldThrow = true

Example

string price = "19.99";
decimal parsedPrice = price.ToDecimal(); // returns 19.99m

string invalid = "abc";
float parsedFloat = invalid.ToFloat(); // returns 0f

char letter = "A".ToChar(); // returns 'A'

Error Handling

All methods support a shouldThrow parameter:

  • false (default): returns default value on failure
  • true: throws ArgumentException with a helpful message
string input = "NaN";
double result = input.ToDouble(shouldThrow: true); 
// Throws: ArgumentException: Unable to convert 'NaN' to 'double'

License

This project is licensed under the GNU GENERAL PUBLIC LICENSE.


Feedback & Contributions

Feel free to open issues or submit pull requests to improve functionality or add new parsing types!


Let me know if you'd like a logo, badges, or CI/CD instructions added to the README!

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 131 8/17/2025