Still working through session 6 of the Summer of Nhibernate and got to the bit where Steve is creating a criteria expression. He’s converting an IList<int> to an array of ints using a ToArray method.
This conversion method doesn’t appear to be standard for IList and as I’m in a bit of a hurry today I’ve assumed it’s an extension method and wrote my own (code below) so I can follow the screen cast:
public static class MyExtensions
{
public static T[] ToArray<T>(this IList<T> ListToConvert)
{
T[] arrayToReturn = new T[ListToConvert.Count];
for (int i = 0; i < arrayToReturn.Length; i++)
arrayToReturn[i] = ListToConvert[i];
return arrayToReturn;
}
}
Advertisement