//-----------------------------------------------------------------------
// <copyright file="ArrayUtil.cs" company="Pyramid Consulting">
// Copyright (c) Pyramid Consulting. All rights reserved.
// khoa.tran - 15-Dec-2007
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.Collections;
using System.Text;
namespace Bamboo.Core.Common.Collection
{
/// <summary>
/// Convert a IList to an array with a specific type.
/// </summary>
/// <typeparam name="T"></typeparam>
public class ArrayUtil<T>
{
public delegate T ConvertMethod(object input);
public static T[] ConvertListToArray(IList inputList, ConvertMethod method)
{
T[] ouput = null;
if (inputList != null)
{
ouput = new T[inputList.Count];
for (int i = 0; i < inputList.Count; i++)
{
ouput[i] = method.Invoke(inputList[i]);
}
}
return ouput;
}
}
}
|