Dogan Kirnaz
  • Welcome
  • Setup
    • Quickstart
  • Basics
    • Agent Extensions
    • Audio Extensions
    • Camera Extensions
    • Collision Extensions
    • Coroutine Extensions
    • Encryption Extensions
    • Format Extensions
    • Game Extensions
    • Json Extensions
    • List Extensions
    • Loop Extensions
    • Material Extensions
    • Math Extensions
    • GameObject Extensions
    • Physics Extensions
    • Object Pool Extensions
    • Scene Extensions
    • PlayerPrefs Extensions
  • Support
    • Support
Powered by GitBook
On this page
  1. Basics

Loop Extensions

For Each

This performs an action on each element of a collection: list, array, dictionary, or enumerable.

List<int> list = new List<int> { 1, 2, 3 };

list .ForEach(num => Debug.Log(num));
int[] array = new int[] { 1, 2, 3 };

array.ForEach(num => Debug.Log(num));
Dictionary<string, int> dictionary = new Dictionary<string, int> { { "Alice", 100 }, { "Bob", 80 } };

dictionary.ForEach((key, value) => Debug.Log($"{key}: {value}"));
IEnumerable<int> enumerable = new List<int> { 1, 2, 3 };

enumerable.ForEach(num => Debug.Log(num));
PreviousList ExtensionsNextMaterial Extensions

Last updated 23 days ago