CSTypes 1.0.6

dotnet add package CSTypes --version 1.0.6
                    
NuGet\Install-Package CSTypes -Version 1.0.6
                    
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="CSTypes" Version="1.0.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CSTypes" Version="1.0.6" />
                    
Directory.Packages.props
<PackageReference Include="CSTypes" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CSTypes --version 1.0.6
                    
#r "nuget: CSTypes, 1.0.6"
                    
#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.
#:package CSTypes@1.0.6
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CSTypes&version=1.0.6
                    
Install as a Cake Addin
#tool nuget:?package=CSTypes&version=1.0.6
                    
Install as a Cake Tool

CSTypes


C# Types Argument Parser


Description CREATED BY: [Latency McLaughlin] UPDATED: 10/12/2026 FRAMEWORKS: net45, net451, net452, net46, net461, net462, net47, net471, net472, net48, net481, netstandard2.0, netstandard2.1, net8.0, net9.0, net10.0, net11.0 LANGUAGE: [C#] preview OUTPUT TYPE: Library [API] SUPPORTS: [Visual Studio] GFX SUBSYS: [None] TAGS: [ArgInterpreter], [CSTypes], [C#] STATUS: workflow-badge LICENSE: license-badge VERSION: 1.0.6



Introduction

CSTypes is a lightweight C# utility library for text-driven games and command-style applications. It provides:

  • Command parsing: split input into words, lines, or a command and its remainder with ArgInterpreter, and peel off words with CopyFirstWord and AdvWord.
  • Dice and random numbers: roll dice (Dice), generate bounded random numbers (Number), and format ordinals such as 1st, 2nd and 3rd (NumericSuffix).
  • Validation helpers: check for whole numbers (IsNumber) and valid IPv4/IPv6 addresses (IsValidIP).
  • Security helpers: generate salt keys and SHA-256 salted hashes for storing passwords.

The library multi-targets .NET Framework 4.5 through 4.8.1, .NET Standard 2.0/2.1, and .NET 8 through .NET 11.

Usage

ArgInterpreter

Tokenizes a string into Tokens (List<string>).

Member Description
ArgInterpreter(string str, ArgTypes type = ArgTypes.Words) Tokenizes str according to type.
Tokens The resulting tokens.
ToString() Joins the tokens with a single space.

ArgTypes

Value Description
Words Tokenize the string into words.
Cut Cut after the first word of the string.
Lines Tokenize the string into lines.

Types (static)

Method Description
string CopyFirstWord(string s) Returns the first word of a string.
string AdvWord(string text, bool withPunctuation = false) Returns the string with its first word skipped, optionally treating punctuation as delimiters.
void Swap<T>(ref T x, ref T y) Swaps two values.
int Number(int minValue, int maxValue) Returns a random number in the range; reversed bounds are swapped.
int Dice(int number, int size) Simulates rolling number dice with size sides. Returns 0 for non-positive arguments.
bool IsNumber(string str) Checks whether a string is a whole number.
bool IsValidIP(string addr) Validates IPv4 and IPv6 addresses (full and compressed).
string NumericSuffix(int number) Returns the ordinal suffix of a number (st, nd, rd, th).
byte[] GenerateSaltKey() Generates a random 8-byte salt key.
byte[] GenerateSaltedHash(byte[] plainText, byte[] salt) Generates a SHA-256 salted hash.

Installation

This library can be installed using NuGet found here.

License

The source code for the site is licensed under the MIT license, which you can find in the MIT-LICENSE.txt file.


Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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 is compatible.  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 is compatible.  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.  net11.0 is compatible. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net45 is compatible.  net451 is compatible.  net452 is compatible.  net46 is compatible.  net461 is compatible.  net462 is compatible.  net463 was computed.  net47 is compatible.  net471 is compatible.  net472 is compatible.  net48 is compatible.  net481 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.6 0 10/13/2026
1.0.5 340 4/12/2024
1.0.4 1,462 10/2/2017