TraunisExtensions 2.0.0

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

Trauni's Extensions

NuGet License: MIT

A small collection of useful C# extension methods and utilities to enhance your .NET development experience.

Installation

Install the package via NuGet Package Manager: dotnet add package TraunisExtensions Or via Package Manager Console: Install-Package TraunisExtensions

Features

Collection Extensions

Foreach Extensions

Execute actions on collections with enhanced foreach methods: using TraunisExtensions;

// Execute action on each element var numbers = new[] { 1, 2, 3, 4, 5 }; numbers.Foreach(x ⇒ Console.WriteLine(x * 2));

// Transform and return new collection var doubled = numbers.ForeachReturn(x ⇒ x * 2);

2D Array Extensions

Array Rotation

Rotate 2D arrays by 90 degrees to the right: int[,] matrix = { { 1, 2 }, { 3, 4 } }; var rotated = matrix.Rotate(); // Result: { { 3, 1 }, { 4, 2 } }

2D Array Iteration

Iterate through 2D arrays with position information: int[,] grid = { { 1, 2, 3 }, { 4, 5, 6 } };

// Execute action on each element with coordinates grid.Foreach((x, y, value) ⇒ Console.WriteLine($"[{x},{y}] = {value}"));

// Execute action on selected elements only grid.Foreach((x, y, value) ⇒ Console.WriteLine($"Even: {value}"), value ⇒ value % 2 == 0);

Array Analysis

Find specific values in 2D arrays: int[,] data = { { 0, 1, 0 }, { 0, 0, 1 }, { 1, 0, 0 } };

// Get the lowest row index where condition is true in column 1 int row = data.GetLowestValueAtColumn(value ⇒ value == 1, column: 1);

Array Size Information

Get array dimensions as a Size object: var size = matrix.GetSize(); // Returns Size(width, height)

Point Extensions

Enhanced Point operations for graphics and coordinate manipulation: using System.Drawing;

Point p1 = new Point(10, 20); Point p2 = new Point(5, 15);

// Add points Point sum = p1.Add(p2); // (15, 35) Point offset = p1.Add(5, 10); // (15, 30)

// Multiply points Point product = p1.Multiply(p2); // (50, 300) Point scaled = p1.Multiply(3); // (30, 60)

// Set console cursor position p1.SetAsConsoleCursorPosition(); // Sets cursor to (10, 20)

Object Cloning

Create deep clones of objects using reflection: var original = new MyClass { Property1 = "value", Property2 = 42 }; var clone = original.Clone(); Note: The Clone method uses reflection and creates a shallow copy for reference types within the object.

Enum Extensions

High-performance flag checking for enums: [Flags] enum MyFlags { None = 0, Flag1 = 1, Flag2 = 2, Flag3 = 4 }

MyFlags flags = MyFlags.Flag1 | MyFlags.Flag3; bool hasFlag = flags.FastHasFlag(MyFlags.Flag1); // true

Requirements

  • .NET 6.0 or later
  • System.Drawing (for Point extensions)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request to the GitHub repository.

License

This project is licensed under the MIT License - see the LICENSE for details.

Author

Elias Traunbauer (trauni)

Version History

  • 2.0.0 - Current version with collection, array, point, and enum extensions
  • Enhanced foreach methods for collections and arrays
  • 2D array manipulation and analysis tools
  • Point arithmetic operations
  • Object cloning utilities
  • High-performance enum flag checking

For more information and updates, visit the GitHub repository.

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
2.0.0 124 8/4/2025
1.1.1 252 7/11/2023
1.1.0 200 7/11/2023
1.0.2 207 7/11/2023
1.0.1 262 11/2/2022
1.0.0 243 11/2/2022