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)
Dependencies
.NETFramework 4.0
No dependencies.
No dependencies.
No dependencies.
No dependencies.
Tags
``` 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
}
```.