-
January 27th, 2018, 11:54 PM
#1
Eliminate LINQ for List<int> ?
I have the example below, I want to cancel LINQ how to write ?
Code:
static void Main()
{
List<int> list = new List<int>();
list.Add(7);
list.Add(11);
list.Add(13);
// See if any elements with values greater than 10 exist.
bool exists = list.Exists(element => element > 10);
Console.WriteLine(exists);
// Check for numbers less than 7.
exists = list.Exists(element => element < 7);
Console.WriteLine(exists);
}
-
January 29th, 2018, 08:48 AM
#2
Re: Eliminate LINQ for List<int> ?
Loop through the items with a foreach loop and compare each item. When you find an item that meets the criteria, set the flag and break.
-
February 3rd, 2018, 03:28 AM
#3
Re: Eliminate LINQ for List<int> ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|