Select IEnumerable with function - CSharp System.Collections.Generic

CSharp examples for System.Collections.Generic:IEnumerable

Description

Select IEnumerable with function

Demo Code

/*The contents of this file are subject to the Mozilla Public License Version 1.1
(the "License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License at http://www.mozilla.org/MPL/

Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
the specific language governing rights and limitations under the License.

The Original Code is the TSOClient./*w  w  w. j  a va 2 s . co  m*/

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