Mar 10, 2016

If value exists in the array

Just a small code snippet to check if given value exists in an array. This is for integer, but can be applied to any type.

        public static bool isInIntArray(int[] _array,int _val)
        {
            if ((Array.IndexOf(_array, _val)) > -1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

In CRM, I use this especially when need to compare option set values for complex logics.

Cheers!

No comments:

Post a Comment