Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. C# 3’s lambda etc..... Do I really need this

C# 3’s lambda etc..... Do I really need this

Scheduled Pinned Locked Moved The Lounge
csharplinqcomfunctional
37 Posts 27 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K keencomputer

    Do I really need to learn this C# 3’s lambda whatever...........

    Tapas Shome System Software Engineer Keen Computer Solutions 1408 Erin Street Winnipeg, Manitoba Canada R3E 2S8 http://www.keencomputer.com www.ias-research.com/blog

    K Offline
    K Offline
    keozcigisoft
    wrote on last edited by
    #25

    It's C# 4.0 already and you are asking what has become an everyday tool :S

    1 Reply Last reply
    0
    • K keencomputer

      Do I really need to learn this C# 3’s lambda whatever...........

      Tapas Shome System Software Engineer Keen Computer Solutions 1408 Erin Street Winnipeg, Manitoba Canada R3E 2S8 http://www.keencomputer.com www.ias-research.com/blog

      M Offline
      M Offline
      msusur
      wrote on last edited by
      #26

      Yeah you need to! As Dario said, it should have only 10 minutes to learn it. If you had start learning it instead of asking here you have already learnt it.

      1 Reply Last reply
      0
      • P Pete OHanlon

        Errm - they aren't just for C#, and no you don't. You could just continue coding with gotos and monolithic procedures if you really wanted to. After all, who needs these fancy, schmancy features? Productivity is for wimps after all.

        "WPF has many lovers. It's a veritable porn star!" - Josh Smith

        As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

        My blog | My articles | MoXAML PowerToys | Onyx

        A Offline
        A Offline
        Adriaan Davel
        wrote on last edited by
        #27

        Pete O'Hanlon wrote:

        Productivity is for wimps after all.

        Spoken like a true Klingon

        ____________________________________________________________ Be brave little warrior, be VERY brave

        1 Reply Last reply
        0
        • M MidwestLimey

          Unless, of course, he never used anonymous methods either ....

          10110011001111101010101000001000001101001010001010100000100000101000001000111100010110001011001011

          T Offline
          T Offline
          thedavejay
          wrote on last edited by
          #28

          Yes, Lambda is important to learn. From what I have seen, people are starting to move more towards functional programming. Its also important to learn to utilize the generic delegates Action<> and Func<>, anonymous methods using lambda expressions (all important parts to functional programming).

          1 Reply Last reply
          0
          • K keencomputer

            Do I really need to learn this C# 3’s lambda whatever...........

            Tapas Shome System Software Engineer Keen Computer Solutions 1408 Erin Street Winnipeg, Manitoba Canada R3E 2S8 http://www.keencomputer.com www.ias-research.com/blog

            S Offline
            S Offline
            ScottM1
            wrote on last edited by
            #29

            keencomputer wrote:

            Keen Computer Solutions

            You don't seem that keen. ;P

            1 Reply Last reply
            0
            • C Chris Meech

              Absolutely. Become a good shepherd and learn all about lambs, ... Oh my bad. You said lambda. Sorry. :)

              Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]

              G Offline
              G Offline
              Gary Wheeler
              wrote on last edited by
              #30

              It puts the lotion on its skin or it gets the hose again...

              Software Zen: delete this;

              1 Reply Last reply
              0
              • J J Dunlap

                No, you don't *have* to, but they're extremely useful and I'd highly recommend it. I wrote an article to help out with the learning process: Lambda Expressions and Expression Trees: An Introduction[^] </shameless-plug> Also check out extension methods because a lot of the places where lambdas are used involve extension methods as well. (Whoa, that's cool! :omg: I pasted the link to my article and it automatically put in the link with the article's title! Good work Chris and co! :cool: )

                D Offline
                D Offline
                duwkes
                wrote on last edited by
                #31

                First off, great article. Secondly, I've been avoiding lambda expressions because my boss hates unnecessary complexity. Funny thing is that we've been adding complexity by using delegates! With such a concise article, I think it will be much easier to get him to realize that they are a good thing. Thanks again!

                J 1 Reply Last reply
                0
                • P Pete OHanlon

                  Errm - they aren't just for C#, and no you don't. You could just continue coding with gotos and monolithic procedures if you really wanted to. After all, who needs these fancy, schmancy features? Productivity is for wimps after all.

                  "WPF has many lovers. It's a veritable porn star!" - Josh Smith

                  As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

                  My blog | My articles | MoXAML PowerToys | Onyx

                  V Offline
                  V Offline
                  vettbird
                  wrote on last edited by
                  #32

                  What's wrong with using the query language instead of Lambda?

                  T 1 Reply Last reply
                  0
                  • K keencomputer

                    Do I really need to learn this C# 3’s lambda whatever...........

                    Tapas Shome System Software Engineer Keen Computer Solutions 1408 Erin Street Winnipeg, Manitoba Canada R3E 2S8 http://www.keencomputer.com www.ias-research.com/blog

                    R Offline
                    R Offline
                    rscjeff
                    wrote on last edited by
                    #33

                    Yes - you'll find that they make your life easier when trying to implement predicate methods. In addition, if you ever inherit code that makes use of lambda expressions, wouldn't you want to at least have some semblance of familiarity? The better question is, do you *have* to know this? Answer is no. Lambda expressions are there to help, not replace.

                    1 Reply Last reply
                    0
                    • D duwkes

                      First off, great article. Secondly, I've been avoiding lambda expressions because my boss hates unnecessary complexity. Funny thing is that we've been adding complexity by using delegates! With such a concise article, I think it will be much easier to get him to realize that they are a good thing. Thanks again!

                      J Offline
                      J Offline
                      J Dunlap
                      wrote on last edited by
                      #34

                      Awesome - glad I could help!

                      1 Reply Last reply
                      0
                      • S Shelby Robertson

                        Yes. And I must add that after you get used to using them there are some excellent everyday uses.

                        Ennis Ray Lynch, Jr. wrote:

                        Unpaid overtime is slavery.

                        Trollslayer wrote:

                        Meetings - where minutes are taken and hours are lost.

                        T Offline
                        T Offline
                        tec goblin
                        wrote on last edited by
                        #35

                        They are short, efficient, clear, and named after a Greek letter :P. What else do you need to love them? :-D

                        1 Reply Last reply
                        0
                        • V vettbird

                          What's wrong with using the query language instead of Lambda?

                          T Offline
                          T Offline
                          tec goblin
                          wrote on last edited by
                          #36

                          You can't use the query language everywhere you could use a Lamda. You can for example create a method that takes a Func as an argument, but is not based on an IQueryable. then you can call the method as this DoSomething(s=>s.Trim()); and later DoSomething(s=>Regex.Replace(s,aPattern,string.Empty); I also prefer to use lamdas instead of queries when I have trivial operations like:

                          var s = Subscribers.Where(s=>s.Id == 3);

                          While I would use a query form for something more complex (for readability), like:

                          var results = from r in context.SearchDatabase(category, name)
                          join s in Subscribers on r.Subscriber equals s.Id
                          select s;

                          1 Reply Last reply
                          0
                          • P Pete OHanlon

                            He should start off on learning to dance the salsa before moving onto the lambada.

                            "WPF has many lovers. It's a veritable porn star!" - Josh Smith

                            As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

                            My blog | My articles | MoXAML PowerToys | Onyx

                            C Offline
                            C Offline
                            CalvinHobbies
                            wrote on last edited by
                            #37

                            I can see this getting bleeted to death like a dead donkey.

                            ///////////////// Groucho Marx Those are my principals, if you don't like them… I have others.

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups