Dawn.ValueString 2.1.0

.NET Standard 1.0 .NET Framework 3.5
dotnet add package Dawn.ValueString --version 2.1.0
NuGet\Install-Package Dawn.ValueString -Version 2.1.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="Dawn.ValueString" Version="2.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Dawn.ValueString --version 2.1.0
#r "nuget: Dawn.ValueString, 2.1.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Dawn.ValueString as a Cake Addin
#addin nuget:?package=Dawn.ValueString&version=2.1.0

// Install Dawn.ValueString as a Cake Tool
#tool nuget:?package=Dawn.ValueString&version=2.1.0

ValueString is intended to be used for convenience when there is a need to initialize typed instances from culture-neutral (invariant) strings - often read from a simple configuration file or a database table.

// ValueString uses the invariant culture when converting
// objects to string if they implement IFormattable.
// So the following value contains "1.5" (dot-separated) even if (1.5).ToString()
// returns "1,5" (comma-separated) due to the current culture.
var value = ValueString.Of(1.5);

// "As" method uses the invariant culture by default.
// It also has an overload accepting an IFormatProvider.
var number = value.As<double>(); // Calls double.Parse.

// Nullable values are supported.
value = ValueString.Of(default(double?));
number = value.As<double>(); // Throws an InvalidCastException.
var nullable = value.As<double?>(); // null.

// Enums are supported.
value = ValueString.Of("Red"); // Enum field name.
var red = value.As<ConsoleColor>();

value = ValueString.Of("12"); // Enum field value.
var green = value.As<ConsoleColor>();

// You can also cast a "dynamic" ValueString to the target type directly.
dynamic d = value;
number = (double)d;

// "Is" is just like "As", but calls the type's TryParse method instead of Parse.
value = ValueString.Of("1.1.1.1");
if (value.Is(out IPAddress address)) // Calls IPAddress.TryParse.
    Console.WriteLine("The IP address is: {0}", address);

// An implicit operator exists converting strings to ValueString instances.
value = "1.5";

See the full readme for the information regarding the other functions, internals, performance and special cases.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp1.0 netcoreapp1.1 netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard1.0 netstandard1.1 netstandard1.2 netstandard1.3 netstandard1.4 netstandard1.5 netstandard1.6 netstandard2.0 netstandard2.1
.NET Framework net35 net40 net403 net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen30 tizen40 tizen60
Universal Windows Platform uap uap10.0
Windows Phone wp8 wp81 wpa81
Windows Store netcore netcore45 netcore451
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Dawn.ValueString:

Package Downloads
OpenSoftware.OptionParser

OptionParser is a library that deals with option parsing and option handling for command-line (CLI) programs.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.0 2,322 3/15/2018
2.0.0 1,930 12/5/2017
1.5.0 746 12/4/2017
1.4.1 747 11/30/2017
1.4.0 713 11/22/2017
1.3.2 909 11/17/2017
1.3.1 932 11/15/2017
1.3.0 909 11/13/2017
1.2.2 936 11/12/2017
1.2.1 931 11/12/2017
1.2.0 922 11/9/2017
1.1.1 919 10/29/2017
1.1.0 709 10/27/2017
1.0.2 704 10/13/2017
1.0.1 816 12/5/2016
1.0.0 969 12/3/2016
0.1.0 1,364 11/29/2016

The assembly no longer has SecurityTransparentAttribute.