FluentParsing 1.0.0
dotnet add package FluentParsing --version 1.0.0
NuGet\Install-Package FluentParsing -Version 1.0.0
<PackageReference Include="FluentParsing" Version="1.0.0" />
<PackageVersion Include="FluentParsing" Version="1.0.0" />
<PackageReference Include="FluentParsing" />
paket add FluentParsing --version 1.0.0
#r "nuget: FluentParsing, 1.0.0"
#:package FluentParsing@1.0.0
#addin nuget:?package=FluentParsing&version=1.0.0
#tool nuget:?package=FluentParsing&version=1.0.0
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 failuretrue
: throwsArgumentException
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 | Versions 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. |
-
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 |