CodeExtensions 1.0.1

dotnet add package CodeExtensions --version 1.0.1
                    
NuGet\Install-Package CodeExtensions -Version 1.0.1
                    
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="CodeExtensions" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CodeExtensions" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="CodeExtensions" />
                    
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 CodeExtensions --version 1.0.1
                    
#r "nuget: CodeExtensions, 1.0.1"
                    
#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 CodeExtensions@1.0.1
                    
#: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=CodeExtensions&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=CodeExtensions&version=1.0.1
                    
Install as a Cake Tool

About

CodeExtensions provides extension methods for various type conversions and validations.

Key Features

Conversions

<ul> <li>CheckBoolean(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a boolean value.</i></li> <li>CheckBooleanNullable(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a nullable boolean value.</i></li> <li>CheckByte(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a byte value.</i></li> <li>CheckByteArray(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a byte array.</i></li> <li>CheckByteNullable(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a nullable byte value.</i></li> <li>CheckChar(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a char value.</i></li> <li>CheckCharArray(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a char array.</i></li> <li>CheckCharNullable(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a nullable char value.</i></li> <li>CheckDate(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a DateTime value.</i></li> <li>CheckDateNullable(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a nullable DateTime value.</i></li> <li>CheckDateTimeOffset(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a DateTimeOffset value.</i></li> <li>CheckDateTimeOffsetNullable(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a nullable DateTimeOffset value.</i></li> <li>CheckDecimal(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a decimal value.</i></li> <li>CheckDecimalNullable(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a nullable decimal value.</i></li> <li>CheckDouble(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a double value.</i></li> <li>CheckDoubleNullable(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a nullable double value.</i></li> <li>CheckFloat(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a float value.</i></li> <li>CheckFloatNullable(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a nullable float value.</i></li> <li>CheckGuid(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a Guid, or Guid.Empty if conversion fails.</i></li> <li>CheckGuidNullable(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a nullable Guid.</i></li> <li>CheckInt16(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a short (Int16) value.</i></li> <li>CheckInt16Nullable(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a nullable short (Int16) value.</i></li> <li>CheckInt32(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to an int (Int32) value.</i></li> <li>CheckInt32Nullable(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a nullable int (Int32) value.</i></li> <li>CheckInt64(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a long (Int64) value.</i></li> <li>CheckInt64Nullable(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a nullable long (Int64) value.</i></li> <li>CheckInteger(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to an integer value.</i></li> <li>CheckIntegerNullable(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a nullable integer value.</i></li> <li>CheckSByte(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to an sbyte value.</i></li> <li>CheckSByteNullable(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a nullable sbyte value.</i></li> <li>CheckString(this object value, bool TrimAll = true)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a string, optionally trimming whitespace.</i></li> <li>CheckTimeSpan(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a TimeSpan value.</i></li> <li>CheckTimeSpanNullable(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a nullable TimeSpan value.</i></li> <li>CheckUInt16(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a uint value.</i></li> <li>CheckUInt16Nullable(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a nullable uint value.</i></li> <li>CheckUInt32(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a ushort value.</i></li> <li>CheckUInt32Nullable(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a nullable ushort value.</i></li> <li>CheckUInt64(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a ulong value.</i></li> <li>CheckUInt64Nullable(this object value)<br> <i style="font-size: smaller;color:#3498db">Converts an object to a nullable ulong value.</i></li> <li>ConvertToSQLString(this string str, AssignQuotes assignQuotes)<br> <i style="font-size: smaller;color:#3498db">Converts a string to a SQL-safe string, optionally wrapping in single quotes.</i></li> <li>DataTableToList<T>(this DataTable dt)<br> <i style="font-size: smaller;color:#3498db">Converts a DataTable to a list of objects of type T.</i></li> <li>GetDataRow<T>(DataRow dr)<br> <i style="font-size: smaller;color:#3498db">Converts a DataRow to an object of type T.</i></li> <li>In<T>(this T item, params T[] items)<br> <i style="font-size: smaller;color:#3498db">Returns true if the item is found in the provided list of items.</i></li> <li>IsBetween(this DateTime date, DateTime start, DateTime end)<br> <i style="font-size: smaller;color:#3498db">Returns true if the date is between the start and end dates (inclusive).</i></li> <li>ToDataTable<T>(this List<T> items)<br> <i style="font-size: smaller;color:#3498db">Converts a list of objects to a DataTable.</i></li> <li>ToEnum<T>(this string value)<br> <i style="font-size: smaller;color:#3498db">Converts a string to its enum equivalent.</i></li> <li>ToInteger(this string value)<br> <i style="font-size: smaller;color:#3498db">Converts a string to an integer value.</i></li> <li>ToLong(this string value)<br> <i style="font-size: smaller;color:#3498db">Converts a string to a long value.</i></li> <li>ToShort(this string value)<br> <i style="font-size: smaller;color:#3498db">Converts a string to a short value.</i></li> </ul>

Validations

<ul> <li>IsDate(this Object obj)<br> <i style="font-size: smaller;color:#3498db">Checks if the object can be parsed as a valid date.</i></li> <li>IsDecimal(this string stringToTest)<br> <i style="font-size: smaller;color:#3498db">Checks if the string can be parsed as a decimal.</i></li> <li>IsDouble(this string stringToTest)<br> <i style="font-size: smaller;color:#3498db">Checks if the string can be parsed as a double.</i></li> <li>IsGuid(this Object obj)<br> <i style="font-size: smaller;color:#3498db">Checks if the object can be parsed as a Guid.</i></li> <li>IsInt16(this string stringToTest)<br> <i style="font-size: smaller;color:#3498db">Checks if the string can be parsed as a short (Int16).</i></li> <li>IsInt32(this string stringToTest)<br> <i style="font-size: smaller;color:#3498db">Checks if the string can be parsed as an int (Int32).</i></li> <li>IsInt64(this string stringToTest)<br> <i style="font-size: smaller;color:#3498db">Checks if the string can be parsed as a long (Int64).</i></li> <li>IsIntEqualTo(this string input, int value)<br> <i style="font-size: smaller;color:#3498db">Checks if the string represents an integer equal to the specified value.</i></li> <li>IsIntGreaterThan(this string input, int value)<br> <i style="font-size: smaller;color:#3498db">Checks if the string represents an integer greater than the specified value.</i></li> <li>IsIntGreaterThanAndLessThan(this string input, int low, int high)<br> <i style="font-size: smaller;color:#3498db">Checks if the string represents an integer greater than low and less than high.</i></li> <li>IsInteger(this string stringToTest)<br> <i style="font-size: smaller;color:#3498db">Checks if the string can be parsed as an integer.</i></li> <li>IsNullOrEmpty(this string? value)<br> <i style="font-size: smaller;color:#3498db">Returns true if the string is null or empty.</i></li> <li>IsNullOrEmpty<T>(this IEnumerable<T>? source)<br> <i style="font-size: smaller;color:#3498db">Returns true if the IEnumerable is null or has no elements.</i></li> <li>IsNullOrWhiteSpace(this string? value)<br> <i style="font-size: smaller;color:#3498db">Returns true if the string is null or whitespace.</i></li> <li>IsNumeric(this string stringToTest, bool intOnly = false)<br> <i style="font-size: smaller;color:#3498db">Checks if the string is numeric (optionally only integer types).</i></li> <li>IsValidYear(this Object obj)<br> <i style="font-size: smaller;color:#3498db">Checks if the object represents a valid year (from 1/1/1900 forward).</i></li> <li>NullIfEmpty(this string? value)<br> <i style="font-size: smaller;color:#3498db">Converts an empty string to null.</i></li> </ul>

LoneWorx.com

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 was computed.  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.  net10.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

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.1 94 8/12/2025
1.0.0 50 5/31/2025