CodeExtensions 1.1.0

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

CodeExtensions

About

CodeExtensions provides extension methods for various type conversions and validations.

Framework Support

  • .NET 6.0
  • .NET 8.0
  • .NET 9.0
  • .NET 10.0

Key Features

Conversions

  • CheckBoolean(this object value)
    Converts an object to a boolean value.

  • CheckBooleanNullable(this object value)
    Converts an object to a nullable boolean value.

  • CheckByte(this object value)
    Converts an object to a byte value.

  • CheckByteArray(this object value)
    Converts an object to a byte array.

  • CheckByteNullable(this object value)
    Converts an object to a nullable byte value.

  • CheckChar(this object value)
    Converts an object to a char value.

  • CheckCharArray(this object value)
    Converts an object to a char array.

  • CheckCharNullable(this object value)
    Converts an object to a nullable char value.

  • CheckDate(this object value)
    Converts an object to a DateTime value.

  • CheckDateNullable(this object value)
    Converts an object to a nullable DateTime value.

  • CheckDateTimeOffset(this object value)
    Converts an object to a DateTimeOffset value.

  • CheckDateTimeOffsetNullable(this object value)
    Converts an object to a nullable DateTimeOffset value.

  • CheckDecimal(this object value)
    Converts an object to a decimal value.

  • CheckDecimalNullable(this object value)
    Converts an object to a nullable decimal value.

  • CheckDouble(this object value)
    Converts an object to a double value.

  • CheckDoubleNullable(this object value)
    Converts an object to a nullable double value.

  • CheckFloat(this object value)
    Converts an object to a float value.

  • CheckFloatNullable(this object value)
    Converts an object to a nullable float value.

  • CheckGuid(this object value)
    Converts an object to a Guid, or Guid.Empty if conversion fails.

  • CheckGuidNullable(this object value)
    Converts an object to a nullable Guid.

  • CheckInt16(this object value)
    Converts an object to a short (Int16) value.

  • CheckInt16Nullable(this object value)
    Converts an object to a nullable short (Int16) value.

  • CheckInt32(this object value)
    Converts an object to an int (Int32) value.

  • CheckInt32Nullable(this object value)
    Converts an object to a nullable int (Int32) value.

  • CheckInt64(this object value)
    Converts an object to a long (Int64) value.

  • CheckInt64Nullable(this object value)
    Converts an object to a nullable long (Int64) value.

  • CheckInteger(this object value)
    Converts an object to an integer value.

  • CheckIntegerNullable(this object value)
    Converts an object to a nullable integer value.

  • CheckSByte(this object value)
    Converts an object to an sbyte value.

  • CheckSByteNullable(this object value)
    Converts an object to a nullable sbyte value.

  • CheckString(this object value, bool TrimAll = true)
    Converts an object to a string, optionally trimming whitespace.

  • CheckTimeSpan(this object value)
    Converts an object to a TimeSpan value.

  • CheckTimeSpanNullable(this object value)
    Converts an object to a nullable TimeSpan value.

  • CheckUInt16(this object value)
    Converts an object to a ushort value.

  • CheckUInt16Nullable(this object value)
    Converts an object to a nullable ushort value.

  • CheckUInt32(this object value)
    Converts an object to a uint value.

  • CheckUInt32Nullable(this object value)
    Converts an object to a nullable uint value.

  • CheckUInt64(this object value)
    Converts an object to a ulong value.

  • CheckUInt64Nullable(this object value)
    Converts an object to a nullable ulong value.

  • ConvertToSQLString(this string str, AssignQuotes assignQuotes)
    Converts a string to a SQL-safe string, optionally wrapping in single quotes.

  • DataTableToList<T>(this DataTable dt)
    Converts a DataTable to a list of objects of type T.

  • GetDataRow<T>(DataRow dr)
    Converts a DataRow to an object of type T.

  • In<T>(this T item, params T[] items)
    Returns true if the item is found in the provided list of items.

  • IsBetween(this DateTime date, DateTime start, DateTime end)
    Returns true if the date is between the start and end dates (inclusive).

  • ToDataTable<T>(this List<T> items)
    Converts a list of objects to a DataTable.

  • ToEnum<T>(this string value)
    Converts a string to its enum equivalent.

  • ToInteger(this string value)
    Converts a string to an integer value.

  • ToLong(this string value)
    Converts a string to a long value.

  • ToShort(this string value)
    Converts a string to a short value.

Validations

  • IsDate(this Object obj)
    Checks if the object can be parsed as a valid date.

  • IsDecimal(this string stringToTest)
    Checks if the string can be parsed as a decimal.

  • IsDouble(this string stringToTest)
    Checks if the string can be parsed as a double.

  • IsGuid(this Object obj)
    Checks if the object can be parsed as a Guid.

  • IsInt16(this string stringToTest)
    Checks if the string can be parsed as a short (Int16).

  • IsInt32(this string stringToTest)
    Checks if the string can be parsed as an int (Int32).

  • IsInt64(this string stringToTest)
    Checks if the string can be parsed as a long (Int64).

  • IsIntEqualTo(this string input, int value)
    Checks if the string represents an integer equal to the specified value.

  • IsIntGreaterThan(this string input, int value)
    Checks if the string represents an integer greater than the specified value.

  • IsIntGreaterThanAndLessThan(this string input, int low, int high)
    Checks if the string represents an integer greater than low and less than high.

  • IsInteger(this string stringToTest)
    Checks if the string can be parsed as an integer.

  • IsNullOrEmpty(this string? value)
    Returns true if the string is null or empty.

  • IsNullOrEmpty<T>(this IEnumerable<T>? source)
    Returns true if the IEnumerable is null or has no elements.

  • IsNullOrWhiteSpace(this string? value)
    Returns true if the string is null or whitespace.

  • IsNumeric(this string stringToTest, bool intOnly = false)
    Checks if the string is numeric (optionally only integer types).

  • IsValidDay(this string? strDay, int month, int year)
    Checks if the object represents a valid day (1-31).

  • IsValidMonth(this string? strMonth)
    Checks if the object represents a valid month (1-12).

  • IsValidYear(this string? strYear, int minYear = 1900, int maxYear = int.MaxValue)
    Checks if the object represents a valid year (from 1/1/1900 forward).

  • NullIfEmpty(this string? value)
    Converts an empty string to null.


License

Copyright © 2010-2026 Joe M. Sims

More Information

Visit LoneWorx.com for more tools and libraries.

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.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.1.0 25 3/15/2026
1.0.3 167 11/5/2025
1.0.2 175 11/5/2025
1.0.1 169 8/12/2025
1.0.0 86 5/31/2025

1.1.0
     - Added multi-targeting: net9.0, net10.0
     - Now supports .NET 6.0, 8.0, 9.0, and 10.0
     - No API changes; purely additive framework support.