asked on
Hi experts,
I'm using ASP.NET Core 5.0 MVC. So I'm using C# 9
In my HomeController.cs
I'm using the String.EndsWith Method to work with a string
String.EndsWith Method
https://docs.microsoft.com/en-us/dotnet/api/system.string.endswith?view=net-5.0
I have a string variable holding an email address like this:
This works fine. This if statements checks to make sure the string ends in @yahoo.com
// declare a string variable called strTestEmailAddress
string strTestEmailAddress = "joesmith@yahoo.com";
if (!strTestEmailAddress.ToLower().EndsWith("@yahoo.com"))
{
// if email address ends in @yahoo.com do stuff inside this if statement
}
Is there a way to use EndsWith to check for 2 types of emails?
Sometimes the variable strTestEmailAddress will hold a @yahoo.com email address and other times it will hold a @microsoft.com email address.
So I need to check if the string the variable strTestEmailAddress ends in @yahoo.com OR @microsoft.com
Anyone know the if statement syntax for that?
if ( )
{
// if email address ends in @yahoo.com or @microsoft.com do stuff inside this if statement
}