CSharp - Array Array Converting

Introduction

Array.ConvertAll creates and returns a new array of element type TOutput, calling the supplied Converter delegate to copy over the elements.

Converter is defined as follows:

public delegate TOutput Converter<TInput,TOutput> (TInput input)

The following converts an array of floats to an array of integers:

Demo

using System;
class MainClass/*from   ww  w. j a v  a  2 s .c om*/
{
    public static void Main(string[] args)
    {
        float[] reals = { 1.3f, 1.5f, 1.8f };
        int[] wholes = Array.ConvertAll(reals, r => Convert.ToInt32(r));

        Array.ForEach(wholes, Console.WriteLine);
        
    }
}

Result