Discussion Did I get this explination of LINQ right?

All Replies

  • Tuesday, April 19, 2011 8:29 AM
    Moderator
     
     

    Hi Dave,

    Really impressive article about LINQ!   It's great to hear that you are interested in LINQ, I believe we can discuss about it more in the future.  Please feel free to ping me at misun@microsoft.com.   I love LINQ, see my display image!  HAHA! 

    LINQ's basic is extension methods and Lambda Expression.  Lambda Expression is just like delegates and LINQ methods are based on extension methods. 

    Just one thing in your post I cannot agree.  To use extension methods, we don't need to include "System.Linq" namespace since extension methods are one built-in feature of C# 3.0 or the later version.   C# extension methods are built inside public static class and they are all static methods with "this" keyword on the first parameter. 

    E.g.   The MySort method can be compiled and called without any problems if we don't "use System.Linq".

    =================================================
       public static class MyExtensionMethods
        {
            public static void ShowString(this string value)
            {
                MessageBox.Show(value);
            }
        }

      string s = "Hello";
      s.ShowString();

    =================================================

    For LINQ extension methods, I believe we need to include "System.Linq", since these LINQ entension methods are included in the System.Linq namespace.  For detailed about LINQ to Objects extension methods, please see the class System.Linq.Enumerable, http://msdn.microsoft.com/en-us/library/system.linq.enumerable.aspx.

    Good day!

    Thanks

     


    Michael Sun [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
  • Tuesday, April 19, 2011 12:51 PM
     
     

    Thank you for the feedback. I was trying to say what you said concerning extension methods and obviously I was unclear. I will fix that.

    I'm glad the rest is right, it means I (mostly) understand LINQ! I also love LINQ - it makes a lot of code much faster and easier to write - and what is happening is a lot clearer. You guys did really good designing it.

    thanks - dave


    Very funny video - What's your Metaphor?
  • Wednesday, April 20, 2011 5:49 AM
    Moderator
     
     

    LINQ is really great!  :)  

    Have a nice day!

    Thanks


    Michael Sun [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft