String contains ignorecase
string-contains-ignorecase.aspx
<%@ Page Language="C#" AutoEventWireup="true"%>
<!DOCTYPE html>
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
//this section create a string variable.
string stringPlants = "Cabinet Cherry, Coffee Plant, Carrot Weed, Canada Root";
Label1.Text = "string..................<br />";
Label1.Text += stringPlants;
string wordToCheck = "CHeRRy";
string wordToCheck2 = "Coneflower";
//this line check string exists 'CHeRRy' or not case insensitive.
Boolean result = stringPlants.ToLower().Contains(wordToCheck.ToLower());
//this line check string contains 'Coneflower' or not ignore case.
Boolean result2 = stringPlants.ToLower().Contains(wordToCheck2.ToLower());
Label1.Text += "<br /><br />string contains (CHeRRy) ignore case?......................";
Label1.Text += "<br />" + result.ToString();
Label1.Text += "<br /><br />string contains (Coneflower) ignore case?......................";
Label1.Text += "<br />" + result2.ToString();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>c# example - string contains ignorecase</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:MidnightBlue; font-style:italic;">
c# example - string contains ignorecase
</h2>
<hr width="550" align="left" color="Gainsboro" />
<asp:Label
ID="Label1"
runat="server"
Font-Size="Large"
>
</asp:Label>
<br /><br />
<asp:Button
ID="Button1"
runat="server"
Text="string contains ignorecase"
OnClick="Button1_Click"
Height="40"
Font-Bold="true"
/>
</div>
</form>
</body>
</html>

- How to check whether a string contains any special character
- String contains multiple values
- How to check string array contains a string
- How to convert a hex string to color
- How to convert a string to camelcase
- How to convert a delimited string to a dictionary
- How to convert a string to a double array
- How to write a string to a file
- How to convert a string to a guid
- How to convert a string to a generic list