For example
int[] Array = { 1, 23, 4, 5, 3, 3, 232, 32, };
Array.JustDo(x => Console.WriteLine(x));
I think you're looking for Array.ForEach which doesn't require you to convert to a List<> first.
int[] a = { 1, 23, 4, 5, 3, 3, 232, 32, };
Array.ForEach(a, x => Console.WriteLine(x));
You can use the Array.ForEach method
int[] array = { 1, 2, 3, 4, 5};
Array.ForEach(array, x => Console.WriteLine(x));
or make your own extension method
void Main()
{
int[] array = { 1, 2, 3, 4, 5};
array.JustDo(x => Console.WriteLine(x));
}
public static class MyExtension
{
public static void JustDo<T>(this IEnumerable<T> ext, Action<T> a)
{
foreach(T item in ext)
{
a(item);
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With