如何在 EndsWith 中获得更多值?
例如
if(textbox1.Text.EndsWith("hotmail.com" && "anothermail.com"){
}
Run Code Online (Sandbox Code Playgroud)
该怎么办?
您可以创建一个扩展方法:
public static bool EndsWithAny(this string str, params string[] search)
{
return search.Any(s => str.EndsWith(s));
}
//Call
bool found = str.EndsWithAny("hotmail.com", "anothermail.com");
Run Code Online (Sandbox Code Playgroud)