It is not possible to move through an array without any loops; you can use the ForEach extension method for the List class.
Enumerable.Range(1,100).ToList().ForEach( i => Console.WriteLine(i));
I don’t know why you would like to do this, but the loop may not be written by you, but it will eventually be presented in some part of the code.
EDIT: Any solution presented will have some loop or even two, if you just want to iterate over all elements, you must create an extension in which you hide for each
public static void ForEach<T>(this IEnumerable<T> enumeration, Action<T> action) { if (action == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match); } foreach(T item in enumeration) { action(item); } }
source share