Declaration Part
int[] idx = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 };
Button_Click Event:
int search_Key = Int32.Parse(txtInput.Text);
int chk_value = SearchText(idx, search_Key);
if (chk_value == -1)
{
txtInput.Text = "";
}
Method:
private static int SearchText(int[] arry,int key)
{
for (int idxs=0;idxs < arry.Length;idxs++)
{
if (arry[idxs] == key)
{
return idxs;
}
}
return -1;
} Note: It is a windows Application.