Beispiel #1
0
        public static int GetIndex(this List <FormItem> list, FormItem element, out string newName)
        {
            int index   = -1;
            int max     = 0;
            int thisKey = element.GetHashCode();

            for (int i = 0; i < list.Count; i++)
            {
                int currKey = list[i].GetHashCode();
                if (thisKey == currKey)
                {
                    index = i;
                }
                string name = list[i].ItemName;
                if (name.StartsWith(FormItem.FieldNamePrex, StringComparison.InvariantCultureIgnoreCase))
                {
                    string num = name.Substring(FormItem.FieldNamePrex.Length);
                    int    R;
                    if (int.TryParse(num, out R))
                    {
                        if (R > max)
                        {
                            max = R;
                        }
                    }
                }
            }
            newName = FormItem.FieldNamePrex + Convert.ToString(max + 1);
            return(index);
        }
Beispiel #2
0
        public static int GetIndex(this List <FormItem> list, FormItem element)
        {
            int thisKey = element.GetHashCode();

            for (int i = 0; i < list.Count; i++)
            {
                int currKey = list[i].GetHashCode();
                if (thisKey == currKey)
                {
                    return(i);
                }
            }
            return(-1);
        }