My C# solution for arrays.