To check if string ends with specific word(s)
To check if a string ends with specific word(s) we use EndsWith method. Return type of this method is Boolean.
stringFruit = "Apple";
if (Fruit.EndsWith("e",StringComparison.OrdinalIgnoreCase))
{
Console.WriteLine("Fruit ends with e");
}
Output
Fruit ends with e
Comments
Post a Comment