I need to indicate if the user enters the name of the local machine in the text box. It turned out to be more complicated than I originally thought.
string userInput = inputTextbox.Text.ToLower();
string machineName = Environment.MachineName.ToLower();
bool isLocal = userInput.Equals(machineName ) ||
userInput.Equals(".") ||
userInput.Equals("localhost");
As you can see, it has become quite dirty and overwhelming. For example, the address 127.0.0.1 was not included. Our testing department continues to write bugs every time they find a new name for the house. We need to break this mistake once and for all.
Is there an easier way to do this?
source
share