| Below code will help to find the values exists or not in arraylist. Here we use textbox to find the result
using System;
using System.Collections;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load( object sender, EventArgs e)
{
}
protected void btnCheck_Click( object sender, EventArgs e)
{
ArrayList arrlistval = new ArrayList {"Adam", "Britney", "nicolas", "Rav" };
bool resultval = arrlistval.Contains(txtname.Text.ToLower());
if (resultval)
{
lblmsg.Text = "Name Found in Given list" ;
}
else
{
lblmsg.Text = "Name not found in Given List" ;
}
}
}
| | |