Vst.StringParse NuGet Package

Provides a Parse generic extension method for string that converts string to T and no boxing occurs
``` C#
// The following code does not occur boxing
var a1 = "123".Parse<int>(); // a1 == 123
var a3 = "123".Parse<int?>(); // a3 == 123
```

# Usage example
``` C#
using System;
using System.Globalization;
using StringParse;

void Exmaple1() {
_ = "12".Parse<int>(); // 12
// _ = "ss".Parse<int>(); // throw FormatException

// with default value, Actually call the TryParse method internally
_ = "12".ParseOr(10); // 12
_ = "ss".ParseOr(10); // 10

// with NumberStyles
_ = "F".Parse<int>(NumberStyles.HexNumber); // 15

// parse Nullable
_ = "12".Parse<int?>(); // 12
// _ = "ss".Parse<int?>(); // throw FormatException

// TryParse
_ = "12".TryParse(out int _); // true
_ = "ss".TryParse(out int _); // false

// Parse Enum
_ = "Saturday".ParseEnum<DayOfWeek>(); // DayOfWeek.Saturday
_ = "Saturday".TryParseEnum(out DayOfWeek _); // true
}
```.




Got any Vst.StringParse Question?





Info

Version: 2.0.0.2
Author(s): Vst.h
Last Update: Monday, February 6, 2023
.NET Fiddle: Create the first Fiddle
Project Url: https://github.com/vst-h/StringParse
NuGet Url: https://www.nuget.org/packages/Vst.StringParse


Install
Install-Package Vst.StringParse
dotnet add package Vst.StringParse
paket add Vst.StringParse
Vst.StringParse Download (Unzip the "nupkg" after downloading)

.NETFramework 4.0
  • No dependencies.
.NETStandard 2.0
  • No dependencies.
net5.0
  • No dependencies.
netstandard2.1
  • No dependencies.


Tags



STATS

must-have-score

2.3

avg-downloads-per-day

1

days-since-last-release

417