Another LINQ 101 bug

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike P

    #1

    Another LINQ 101 bug

    I have a problem with using Sequence.Range in the LINQ examples (see
    below) :

    var numbers =
    from n in Sequence.Range( 100, 50)
    select new {Number = n, OddEven = n % 2 == 1 ? "odd" :
    "even"};

    foreach (var n in numbers)
    {
    lbl.Text = "The number " + n.Number + " is " + n.OddEven;
    }
    The error I get is :
    The name 'Sequence' does not exist in the current context

    Can anybody help?



    *** Sent via Developersdex http://www.developersdex.com ***
  • Peter Duniho

    #2
    Re: Another LINQ 101 bug

    On Fri, 22 Aug 2008 08:03:21 -0700, Mike P <mike.parr@gmai l.comwrote:
    I have a problem with using Sequence.Range in the LINQ examples (see
    below) :
    For what it's worth, unless you post a link to the sample you're trying to
    use, it's not very practical for anyone to try to figure out whether the
    sample is wrong or you've just made a mistake using it.

    For example:
    var numbers =
    from n in Sequence.Range( 100, 50)
    select new {Number = n, OddEven = n % 2 == 1 ? "odd" :
    "even"};
    >
    foreach (var n in numbers)
    {
    lbl.Text = "The number " + n.Number + " is " + n.OddEven;
    }
    The error I get is :
    The name 'Sequence' does not exist in the current context
    If the name "Sequence" is invalid, then for some reason it hasn't been
    defined/declared. But since any such declaration would precede the code
    you posted, no one can tell where the declaration would actually be or
    whether or not it's actually in the sample.

    Now, as it happens for this particular question, a quick search on MSDN
    turns up this link:


    It explains that the sample is using a pre-release class that changed
    before LINQ was actually released.

    You should probably submit feedback to Microsoft regarding the sample, to
    point out their error.

    And for future reference, it'll be a lot simpler for people to try to
    answer the questions if you provide a link to the sample in question.

    Pete

    Comment

    Working...