Don and Anders first example not working

Am I missing anything

This is my code:

static void Main(string[] args)

{

string[] names = { "Seba", "Viviana" };

IEnumerable<string> expr = from s in names

select s.ToUpper();

foreach (string item in s)

Console.WriteLine(item);

}

And I get compilation errors




Answer this question

Don and Anders first example not working

  • gladelu

    You have the Using statements correct, but is the custom build action set I don't have my LINQ build handy to check it at the moment.

    There is one bug in your code. On your iterations to print the results to the console, use the following:

    foreach (string item in expr)

    Your variable that you are using is expr. "s" is only internal to the query. Sorry if I lead you in a wild goose chase.

    Jim Wooley
    http://devauthority.com/blogs/jwooley/default.aspx



  • willfried

    Did you create your project using the LINQ template or did you just create it as normal If you created a standard project, I suspect that you are missing either the System.Query namespace or the custom build actions to use the revised compiler. Try creating a new project using the LINQ templates and copy in your code. If this is not the source of the problem, post your compilation errors and we can see what we can do to help further.

    Jim Wooley
    http://devauthority.com/blogs/jwooley/default.aspx



  • Limmy

    I should've said so... yeap I did! I'm pasting my entire code

    using System;

    using System.Collections.Generic;

    using System.Text;

    using System.Query;

    using System.Xml.XLinq;

    using System.Data.DLinq;

    namespace LINQConsoleApplication

    {

    class Program

    {

    static void Main(string[] args)

    {

    string[] names = { "Seba", "Viviana" };

    IEnumerable<string> expr = from s in names

    select s.ToUpper();

    foreach (string item in s)

    Console.WriteLine(item);

    }

    }

    }



  • Don and Anders first example not working