Click here to Skip to main content
15,879,474 members
Home / Discussions / C#
   

C#

 
GeneralRe: necessity to use .Any() to check if an IEnumerable<T> result has no items without iterating over it ? Pin
Richard Deeming16-Jan-22 22:45
mveRichard Deeming16-Jan-22 22:45 
GeneralRe: necessity to use .Any() to check if an IEnumerable<T> result has no items without iterating over it ? Pin
BillWoodruff18-Jan-22 1:19
professionalBillWoodruff18-Jan-22 1:19 
GeneralRe: necessity to use .Any() to check if an IEnumerable<T> result has no items without iterating over it ? Pin
Richard Deeming18-Jan-22 1:41
mveRichard Deeming18-Jan-22 1:41 
GeneralRe: necessity to use .Any() to check if an IEnumerable<T> result has no items without iterating over it ? Pin
BillWoodruff18-Jan-22 3:08
professionalBillWoodruff18-Jan-22 3:08 
GeneralRe: necessity to use .Any() to check if an IEnumerable<T> result has no items without iterating over it ? Pin
Richard Deeming18-Jan-22 6:17
mveRichard Deeming18-Jan-22 6:17 
GeneralRe: necessity to use .Any() to check if an IEnumerable<T> result has no items without iterating over it ? Pin
BillWoodruff19-Jan-22 13:58
professionalBillWoodruff19-Jan-22 13:58 
GeneralRe: necessity to use .Any() to check if an IEnumerable<T> result has no items without iterating over it ? Pin
Richard Deeming19-Jan-22 21:43
mveRichard Deeming19-Jan-22 21:43 
GeneralRe: necessity to use .Any() to check if an IEnumerable<T> result has no items without iterating over it ? Pin
BillWoodruff20-Jan-22 4:26
professionalBillWoodruff20-Jan-22 4:26 
We may not end up eye=>to<=eye on this one ... of course, on a practical level, we both use IEnumerable with skill (for most of us it takes some time to achieve a sense of mastery).

Let me ask you to imagine you are teaching a bright young person how to use Linq: they ask you, one day: "what is an IEnumerable before it gets iterated ?" ... what metaphor, or analogy, would you use to communicate your understanding ?

I run a Linq operator on a collection that returns an IEnumerable<T>: I get a result which is a ""System.Linq.Enumerable+WhereListIterator`1[[System.Int32, System.Private.CoreLib" ... I call that an instance of a special object, a kind of "alternate reality" with some unique methods ('MoveNext, etc. and facilities (deferred execution.

List<int> ints0 = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8 };
var ienm = ints0.Where(itm => itm > 2);
I examine the Type:

> ? ienm.GetType()
{Name = "WhereListIterator`1" FullName = "System.Linq.Enumerable+WhereListIterator`1[[System.Int32, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]"}
    Assembly: {System.Linq, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a}
    AssemblyQualifiedName: "System.Linq.Enumerable+WhereListIterator`1[[System.Int32, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Linq, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    Attributes: NestedPrivate | Sealed | BeforeFieldInit
    BaseType: {Name = "Iterator`1" FullName = "System.Linq.Enumerable+Iterator`1[[System.Int32, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]"}

«The mind is not a vessel to be filled but a fire to be kindled» Plutarch


modified 20-Jan-22 10:33am.

GeneralRe: necessity to use .Any() to check if an IEnumerable<T> result has no items without iterating over it ? Pin
harold aptroot16-Jan-22 22:48
harold aptroot16-Jan-22 22:48 
GeneralRe: necessity to use .Any() to check if an IEnumerable<T> result has no items without iterating over it ? Pin
BillWoodruff18-Jan-22 0:49
professionalBillWoodruff18-Jan-22 0:49 
GeneralRe: necessity to use .Any() to check if an IEnumerable<T> result has no items without iterating over it ? Pin
jschell23-Jan-22 7:40
jschell23-Jan-22 7:40 
GeneralRe: necessity to use .Any() to check if an IEnumerable<T> result has no items without iterating over it ? Pin
BillWoodruff25-Jan-22 3:58
professionalBillWoodruff25-Jan-22 3:58 
GeneralRe: necessity to use .Any() to check if an IEnumerable<T> result has no items without iterating over it ? Pin
jschell30-Jan-22 6:22
jschell30-Jan-22 6:22 
QuestionRemove a page from pdf document in C# Pin
Member 1447460712-Jan-22 20:09
Member 1447460712-Jan-22 20:09 
AnswerRe: Remove a page from pdf document in C# Pin
OriginalGriff12-Jan-22 20:22
mveOriginalGriff12-Jan-22 20:22 
GeneralRe: Remove a page from pdf document in C# Pin
Member 1447460713-Jan-22 5:19
Member 1447460713-Jan-22 5:19 
GeneralRe: Remove a page from pdf document in C# Pin
OriginalGriff13-Jan-22 5:39
mveOriginalGriff13-Jan-22 5:39 
QuestionRoots of polynomial , eigenvalue method Pin
Member 1549773912-Jan-22 6:08
Member 1549773912-Jan-22 6:08 
AnswerRe: Roots of polynomial , eigenvalue method Pin
Victor Nijegorodov12-Jan-22 6:22
Victor Nijegorodov12-Jan-22 6:22 
GeneralRe: Roots of polynomial , eigenvalue method Pin
Member 1549773912-Jan-22 8:33
Member 1549773912-Jan-22 8:33 
AnswerRe: Roots of polynomial , eigenvalue method Pin
Richard Andrew x6412-Jan-22 7:10
professionalRichard Andrew x6412-Jan-22 7:10 
GeneralRe: Roots of polynomial , eigenvalue method Pin
Member 1549773912-Jan-22 8:34
Member 1549773912-Jan-22 8:34 
GeneralRe: Roots of polynomial , eigenvalue method Pin
Richard Andrew x6412-Jan-22 8:38
professionalRichard Andrew x6412-Jan-22 8:38 
AnswerRe: Roots of polynomial , eigenvalue method Pin
Kenneth Haugland15-Jan-22 1:53
mvaKenneth Haugland15-Jan-22 1:53 
QuestionSerial communication between LPC2132 microcontroller and serial interface PC through RS 232 and RJ45 Pin
Member 1549617511-Jan-22 2:06
Member 1549617511-Jan-22 2:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.