How to use string StartsWith() and EntsWith() in C#

StratsWith() – StartsWith() string method check if the parameter string startswith specified string.

EndsWith() – EndsWith() string method check if the parameter string endswith specified string.

How to use StratsWith() and EndsWith() string method in C#

How to use StratsWith() and EndsWith() string method in C#

 

write below code on Stratswith button click events:

protected void Button1_Click(object sender, EventArgs e)
{
string str1 = TextBox1.Text;
string str2 = TextBox2.Text;

Label1.Text = str1.StartsWith(str2).ToString();
}

How to use StratsWith() and EndsWith() string method in C#

How to use StratsWith() and EndsWith() string method in C#

 

write below code on Endswith button click events:

protected void Button2_Click(object sender, EventArgs e)
{
string str1 = TextBox1.Text;
string str2 = TextBox2.Text;

Label1.Text = str1.EndsWith(str2).ToString();
}

How to use StratsWith() and EndsWith() string method in C#

How to use StratsWith() and EndsWith() string method in C#

 

How to use StratsWith() and EndsWith() string method in C#

How to use StratsWith() and EndsWith() string method in C#

Leave a Reply

Your email address will not be published. Required fields are marked *

4 + 2 =


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">