ToolBX.EasyTypeParsing
3.0.0
dotnet add package ToolBX.EasyTypeParsing --version 3.0.0
NuGet\Install-Package ToolBX.EasyTypeParsing -Version 3.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="ToolBX.EasyTypeParsing" Version="3.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ToolBX.EasyTypeParsing --version 3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ToolBX.EasyTypeParsing, 3.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.
// Install ToolBX.EasyTypeParsing as a Cake Addin #addin nuget:?package=ToolBX.EasyTypeParsing&version=3.0.0 // Install ToolBX.EasyTypeParsing as a Cake Tool #tool nuget:?package=ToolBX.EasyTypeParsing&version=3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
EasyTypeParsing
Extension methods to make it easier to parse strings into other types.
public void DoSomeShadyStuff(string aNumberMaybe, string definitelyANumber, string iDontCareIfItsANumber)
{
//A number... maybe? Let's try to parse it into an integer without throwing exceptions
var number = aNumberMaybe.ToInt();
if (number.IsSuccess)
{
//It worked! This is a number!
}
else
{
//It wasn't a number after all :(
}
//If it's definitely a number then we don't have to use white gloves with this one! Convert it or throw in a very savage manner!
var otherNumber = definitelyANumber.ToIntOrThrow();
//This one could be garbage or a number... but I'm okay with getting a big fat zero in case it failed
var meh = iDontCareIfItsANumber.ToIntOrDefault();
}
I can hear you say "It's all well and good but what if I want to parse Dates?!"
public void DoMoreShadyStuff(string disguisedDate)
{
var myDate = disguisedDate.ToDateTimeOrThrow();
}
There are methods for most common primitive and not-so-primitive types.
//You can also do the following if you don't know the type ahead of time
public void IntensifyShadyness<T>(string ummWhatIsThis)
{
var thingy = ummWhatIsThis.Parse<T>();
var definiteThingy = ummWhatIsThis.ParseOrThrow<T>();
var recklessThingy = ummWhatIsThis.ParseOrDefault<T>();
}
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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- ToolBX.OutWarden (>= 3.0.0)
- ToolBX.Reflection4Humans.Extensions (>= 3.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on ToolBX.EasyTypeParsing:
Package | Downloads |
---|---|
ToolBX.Mathemancy
A bundle for generic geometry types such as Vector2<T>, Size<T> and Rectangle<T> |
|
ToolBX.DML.NET
.NET implementation of the Dialog Markup Language. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
3.0.0 | 1,908 | 9/26/2024 |
3.0.0-beta1 | 111 | 9/23/2024 |
2.2.0 | 2,326 | 1/12/2024 |
2.2.0-beta1 | 567 | 11/24/2023 |
2.0.1 | 1,252 | 4/25/2023 |
2.0.0 | 586 | 11/9/2022 |
2.0.0-beta1 | 656 | 9/20/2022 |
1.0.1-beta1 | 159 | 9/20/2022 |
1.0.0 | 8,574 | 12/21/2021 |