I have some class:
public class AddressViewModel
{
public string Index { get; set; }
public string Area { get; set; }
public string StreetName { get; set; }
public string Home { get; set; }
...
}
string specialCharacters = @"~!@#$%^&*_+|{}:""<>?[];'/=\№";
我有检查方法:
private bool CompareCharacters(string specialCharacters, AddressViewModel x)
{
if (x.Index.Any(specialCharacters.Contains) ||
x.Area.Any(specialCharacters.Contains) || ...)
return false;
else
return true;
}
如何重构此方法?我不喜欢“if”语句的实现