public static string GetName(DataStore datastore, string p) { string x = p; while (AlreadyExistInUniqueConstraintNameList(datastore, x)) { string sWithoutNumber = ""; int iNum = GetStringLastNumber(x, ref sWithoutNumber); iNum++; x = sWithoutNumber + iNum; } return x; }
private static bool AlreadyExistInUniqueConstraintNameList(DataStore datastore, string x) { foreach (DataItem dataitem in datastore.items) { if (dataitem.name.Equals(x)) { return true; } } return false; }