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 = @"[email protected]#$%^&*_+|{}:""<>?[];'/=\№";
而且我有檢查方法:檢查屬性值重構
private bool CompareCharacters(string specialCharacters, AddressViewModel x)
{
if (x.Index.Any(specialCharacters.Contains) ||
x.Area.Any(specialCharacters.Contains) || ...)
return false;
else
return true;
}
我如何重構這種方法嗎?我不喜歡「if」語句執行
謝謝你,喬恩。 – zrabzdn
當談到與布爾分配財產,是否有任何正當的理由來選擇'!(x || y)'超過'!x &&!y'或者它只是個人偏好? – Jonesopolis
@Jonesy:如果可能,我寧願避免使用包圍。我發現它更易於閱讀。 –