[Mono-bugs] [Bug 522303] Generics problem with call to ICollection<Array> parameter with Array of Array of strings

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Jul 15 10:38:17 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=522303

User i-ellang at microsoft.com added comment
http://bugzilla.novell.com/show_bug.cgi?id=522303#c1


Elise Langham <i-ellang at microsoft.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |i-ellang at microsoft.com




--- Comment #1 from Elise Langham <i-ellang at microsoft.com>  2009-07-15 08:38:15 MDT ---
Essential for using .NET Generic Collections

Copy of TestArrays.cs file:
-------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Reflection;

namespace TestArrayLengths
{

    public static class MyStringUtil
    {
        public static int Max(ICollection<int> list)
        {
            int max = Int32.MinValue;
            foreach (int item in list)
            {
                max = Math.Max(max, item);
            }
            return max;
        }

        public static ICollection<int> ArrayLengths(ICollection<Array>
arrayList)
        {
            int[] lengths = new int[arrayList.Count];
            int i = 0;
            foreach (Array a in arrayList)
            {
                lengths[i++] = a.Length;
            }
            return lengths;
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            ////create array of arrays of strings

            string[][] lines = new string[5][];
            lines[0] = new string[2];
            lines[1] = new string[] { " " };
            lines[2] = new string[2];
            lines[3] = new string[] { " " };
            lines[4] = new string[2];
            lines[0][0] = "Parameter";
            lines[0][1] = "---------";
            lines[2][0] = "Provided";
            lines[2][1] = "--------";
            lines[4][0] = "Expected";
            lines[4][1] = "--------";

            int nRows = MyStringUtil.Max(MyStringUtil.ArrayLengths(lines));
            Console.WriteLine("value of nRows: {0}", nRows);

        }
    }
}
------------------------------------------------------------------------------

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list