ElegantLoops 1.0.1

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

ElegantLoop

Sometimes, even the simplest things deserve elegance. And this loop is exactly that! You can turn this 💩:

for (int i = 0; i < count; i++)
{
	// Your code inside this overly verbose loop 😡
}

into this 🎂:

foreach (int i in count)
{
	// Your code inside a minimalistic, elegant loop ✨
	// So beautiful it makes your linter weep with joy 😌
}

No more months of debugging because you wrote ⇐ instead of <! No more pondering “is it i++ or ++i this time?”! Just pure, readable iteration.

Uncle Bob might have said: “Every code with loops like this is clean! And every other is not.” — If you disagree, well... I hope your free e-book came with a refund policy. 😉

Benchmarks?

Yes, we did those too. The ElegantLoop holds its ground against the classic for loop, and even wins in many cases. Check the Benchmark project if you’re into raw numbers and bragging rights.

Tests?

Of course! This loop is bulletproof. We’ve tested zero, negative, and mega-huge counts — and it still behaves like a champ. See the tests folder and judge for yourself.

Why?

Because we could. Because it’s funny. And maybe, just maybe… because writing foreach (int i in count) feels good. 😌

Conclusion

You might think you don't need this. But trust me — once you try it, there’s no going back. And guess what? It’s free! …for now 😈

License

This project is licensed under the MIT License — use it freely, copy it shamelessly, but hey — drop a ⭐ if it made you smile.

Inspiration

This project was inspired by a Nick Chapsas. And the video: Adding a BETTER way to loop in C#. I loved the idea and decided to implement my own version with some personal tweaks.

Feedback and Contributions

Feel free to open an Issue for bugs, questions, or suggestions. Pull Requests are also welcome!

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  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 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.
  • net5.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 136 4/7/2025
1.0.0 108 4/6/2025