Select from IEnumerable by function - CSharp System.Collections.Generic

CSharp examples for System.Collections.Generic:IEnumerable

Description

Select from IEnumerable by function

Demo Code

/*This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
If a copy of the MPL was not distributed with this file, You can obtain one at
http://mozilla.org/MPL/2.0/.//www . j av  a  2  s.  c o m

The Original Code is the TSOClient.

The Initial Developer of the Original Code is
ddfczm. All Rights Reserved.

Contributor(s): ______________________________________.
*/
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;

public class Main{
        public static IEnumerable<TResult> Select<TSource, TResult>(this Array items, Func<TSource, TResult> converter)
        {
            var result = new List<TResult>();
            foreach (var item in items)
            {
                result.Add(converter((TSource)item));
            }
            return result;
        }
}

Related Tutorials