示例#1
0
        /* Function: StringPairArraysAreEqual
         * Compares two arrays of string pairs, ignoring the order they exist in.  Is case sensitive and safe to use with nulls.
         */
        public static bool StringPairArraysAreEqual(string[] array1, string[] array2)
        {
            if (array1 == null && array2 == null)
            {
                return(true);
            }
            else if (array1 == null || array2 == null)
            {
                return(false);
            }
            else if (array1.Length != array2.Length)
            {
                return(false);
            }
            else
            {
                Collections.StringSet array1set = new Collections.StringSet();

                for (int i = 0; i < array1.Length; i += 2)
                {
                    array1set.Add(array1[i] + array1[i + 1]);
                }

                for (int i = 0; i < array2.Length; i += 2)
                {
                    if (!array1set.Contains(array2[i] + array2[i + 1]))
                    {
                        return(false);
                    }
                }

                return(true);
            }
        }
示例#2
0
        /* Function: StringArraysAreEqual
         * Compares two arrays of strings, ignoring the order they exist in.  Is case sensitive and safe to use with nulls.
         */
        public static bool StringArraysAreEqual(string[] array1, string[] array2)
        {
            if (array1 == null && array2 == null)
            {
                return(true);
            }
            else if (array1 == null || array2 == null)
            {
                return(false);
            }
            else if (array1.Length != array2.Length)
            {
                return(false);
            }
            else
            {
                Collections.StringSet array1set = new Collections.StringSet();

                foreach (string array1item in array1)
                {
                    array1set.Add(array1item);
                }

                foreach (string array2item in array2)
                {
                    if (!array1set.Contains(array2item))
                    {
                        return(false);
                    }
                }

                return(true);
            }
        }