I'm digging in in my Microsoft Visual Studio Documentation and I found this article under C# Reference (ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.en/dv_csref/html/df01e266-5781-4aaa-80c4-67cf28ea093f.htm), It's about Interface Interface
. Here's the example code:
class SelectSample1
{
static void Main()
{
//Create the data source
List<int> Scores = new List<int>() { 97, 92, 81, 60 };
// Create the query.
IEnumerable<int> queryHighScores =
from score in Scores
where score > 80
select score;
// Execute the query.
foreach (int i in queryHighScores)
{
Console.Write(i + " ");
}
}
}
//Output: 97 92 81
Instead of a List
, is it also possible to query a DataTable
and set the result of the query as the DataSource of a DataGridView
?
If yes, suppose I have this structure:
Fruit | CategoryID
---------------------------------------
Lemon | 1
Orange | 1
Apple | 2
Pear | 2
Can anyone please give me an example (if possible, for a beginner's approach.. :). What I want is to display the result in a DataGridView. Display all fruits where its CategoryID is equal to 1. Please help,
Thanks in advance guys.