Could you please tell me if there is something that can be changed here to make the code in the method better in any terms?
Any suggestions are welcome
C#:
public static string GetUniqueName(List<string> existedNames, string name)
{
name = Regex.Replace(name, @" \([0-9]+\)$", "");
if (existedNames.Any(n => n == name) == false)
return name;
for (int j = 0; j < 1000; j++)
{
var newName = name + " (" + j + ")";
if (existedNames.Any(n => n == newName) == false)
{
return newName;
}
}
return "";
}
Any suggestions are welcome