how to use string method EndWith() in c#

Gow.Net
Posted by Gow.Net under C# category on | Points: 40 | Views : 1519
1.Method 1
 string input = "www.dotnetfunda.com";
string[] arr = new string[] { ".net", ".com", ".in" };
// Loop through and test each string
foreach (string ss in arr)
{
if (input.EndsWith(ss))
{
A.WriteLine(ss);

}
}

2.Method 2

//condition using
string name="Gowthaman Vimal";
if (name.EndsWith("Vimal"))
{
A.WriteLine(name);//endwith "Vimal" true
}
else
{
A.WriteLine("i Can't find");
}

Comments or Responses

Login to post response