//Create an array of Strings
string[] arr = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z".Split(",".ToCharArray());
//Populate listbox with array of strings
ListBox1.DataSource = arr;
//Bind array of strings to Listbox
ListBox1.DataBind();
//Using linq syntex we will query an array of strings and find the word "S" and "M"
var query = from alphabet in arr
where (alphabet == "S" || alphabet == "M")
select alphabet ;
// A query body must end with a select clause or a group clause
foreach(var alpha in query)
{
Response.Write(alpha+"<Br/>"); //Write the word found
}
|