Click here to Skip to main content
15,887,135 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Enough! I quit for the day! Pin
OriginalGriff25-Jan-22 6:40
mveOriginalGriff25-Jan-22 6:40 
GeneralRe: Enough! I quit for the day! Pin
Sander Rossel25-Jan-22 7:58
professionalSander Rossel25-Jan-22 7:58 
GeneralRe: Enough! I quit for the day! Pin
kmoorevs25-Jan-22 8:47
kmoorevs25-Jan-22 8:47 
GeneralRe: Enough! I quit for the day! Pin
Sander Rossel25-Jan-22 9:00
professionalSander Rossel25-Jan-22 9:00 
JokeRe: Enough! I quit for the day! Pin
Daniel Pfeffer26-Jan-22 0:05
professionalDaniel Pfeffer26-Jan-22 0:05 
GeneralRe: Enough! I quit for the day! Pin
DRHuff25-Jan-22 13:54
DRHuff25-Jan-22 13:54 
GeneralRe: Enough! I quit for the day! Pin
Jon McKee25-Jan-22 10:19
professionalJon McKee25-Jan-22 10:19 
GeneralRe: Enough! I quit for the day! Pin
Richard Deeming25-Jan-22 6:43
mveRichard Deeming25-Jan-22 6:43 
OriginalGriff wrote:
The foreach part has been working for hours.
But the Linq stuff? Nope, can't even get it to compile
Sounds like you forgot to implement IEnumerable<T>. Smile | :)

foreach will work with anything that implements the non-generic IEnumaberable, or anything that looks like it implements that:
C#
class Foo // No interface here...
{
    public FooEnumerator GetEnumerator() => new();
}

class FooEnumerator // Nor here...
{
    private bool _done;
    public int Current => 42;
    public bool MoveNext()
    {
        if (_done) return false;
        _done = true;
        return true;
    }
}
C#
Foo x = new();
foreach (int y in x)
{
    Console.WriteLine(y);
}

// Output: 42
LINQ is much more pernickety - if it doesn't implement IEnumerable<T> (or, for the Cast and OfType methods, IEnumerable), then it doesn't work.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

GeneralRe: Enough! I quit for the day! Pin
OriginalGriff25-Jan-22 6:51
mveOriginalGriff25-Jan-22 6:51 
GeneralRe: Enough! I quit for the day! Pin
Marc Clifton25-Jan-22 7:14
mvaMarc Clifton25-Jan-22 7:14 
GeneralRe: Enough! I quit for the day! Pin
OriginalGriff25-Jan-22 7:24
mveOriginalGriff25-Jan-22 7:24 
GeneralRe: Enough! I quit for the day! Pin
theoldfool25-Jan-22 9:03
professionaltheoldfool25-Jan-22 9:03 
GeneralRe: Enough! I quit for the day! Pin
oofalladeez34325-Jan-22 12:20
professionaloofalladeez34325-Jan-22 12:20 
GeneralIs the James Webb Space Telescope now a planet? Pin
Cpichols25-Jan-22 2:10
Cpichols25-Jan-22 2:10 
GeneralRe: Is the James Webb Space Telescope now a planet? PinPopular
Richard MacCutchan25-Jan-22 2:14
mveRichard MacCutchan25-Jan-22 2:14 
GeneralRe: Is the James Webb Space Telescope now a planet? Pin
Daniel Pfeffer25-Jan-22 2:35
professionalDaniel Pfeffer25-Jan-22 2:35 
GeneralRe: Is the James Webb Space Telescope now a planet? Pin
Cpichols25-Jan-22 3:05
Cpichols25-Jan-22 3:05 
GeneralRe: Is the James Webb Space Telescope now a planet? Pin
obermd25-Jan-22 3:34
obermd25-Jan-22 3:34 
GeneralRe: Is the James Webb Space Telescope now a planet? Pin
TNCaver25-Jan-22 5:37
TNCaver25-Jan-22 5:37 
GeneralRe: Is the James Webb Space Telescope now a planet? Pin
Chris C-B25-Jan-22 5:40
Chris C-B25-Jan-22 5:40 
JokeRe: Is the James Webb Space Telescope now a planet? Pin
Daniel Pfeffer25-Jan-22 6:02
professionalDaniel Pfeffer25-Jan-22 6:02 
GeneralRe: Is the James Webb Space Telescope now a planet? Pin
oofalladeez34325-Jan-22 9:13
professionaloofalladeez34325-Jan-22 9:13 
GeneralRe: Is the James Webb Space Telescope now a planet? Pin
TNCaver25-Jan-22 5:36
TNCaver25-Jan-22 5:36 
GeneralRe: Is the James Webb Space Telescope now a planet? Pin
OriginalGriff25-Jan-22 6:12
mveOriginalGriff25-Jan-22 6:12 
GeneralRe: Is the James Webb Space Telescope now a planet? Pin
TNCaver25-Jan-22 6:59
TNCaver25-Jan-22 6:59 

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.