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. I hate technical books that try to sound young...

I hate technical books that try to sound young...

Scheduled Pinned Locked Moved The Lounge
csharptutoriallinqquestionlearning
40 Posts 16 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.
  • OriginalGriffO Offline
    OriginalGriffO Offline
    OriginalGriff
    wrote on last edited by
    #1

    I decided it was time I read up on LINQ: never really used it, time I learnt. So, I have a quick look for a book. Amazon: Sams LINQ Unleashed for C#. Lets have a quick look "Surprise me" "check out Wikipedia; Wikipedia is wicked cool at providing detailed facts" Hmmm. Wicked cool? And a code fragment to illustrate how wonderfull anonymous types are:

           var request = HttpWebRequest.Create(string.Format(url, stock));
            using (var response = request.GetResponse())
                {
                using (var reader = new StreamReader(response.GetResponseStream(), Encoding.ASCII))
                    {
                    return (reader.ReadToEnd());
                    }
                }
    

    I hate that. Why use an example where it is actually clearer if you don't use anonymous types?

            WebRequest request = HttpWebRequest.Create(string.Format(url, stock));
            using (WebResponse response = request.GetResponse())
                {
                using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.ASCII))
                    {
                    return (reader.ReadToEnd());
                    }
                }
    

    Don't think I'll buy that one...

    Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."

    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
    "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

    N N A T M 8 Replies Last reply
    0
    • OriginalGriffO OriginalGriff

      I decided it was time I read up on LINQ: never really used it, time I learnt. So, I have a quick look for a book. Amazon: Sams LINQ Unleashed for C#. Lets have a quick look "Surprise me" "check out Wikipedia; Wikipedia is wicked cool at providing detailed facts" Hmmm. Wicked cool? And a code fragment to illustrate how wonderfull anonymous types are:

             var request = HttpWebRequest.Create(string.Format(url, stock));
              using (var response = request.GetResponse())
                  {
                  using (var reader = new StreamReader(response.GetResponseStream(), Encoding.ASCII))
                      {
                      return (reader.ReadToEnd());
                      }
                  }
      

      I hate that. Why use an example where it is actually clearer if you don't use anonymous types?

              WebRequest request = HttpWebRequest.Create(string.Format(url, stock));
              using (WebResponse response = request.GetResponse())
                  {
                  using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.ASCII))
                      {
                      return (reader.ReadToEnd());
                      }
                  }
      

      Don't think I'll buy that one...

      Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."

      N Offline
      N Offline
      Nish Nishant
      wrote on last edited by
      #2

      Uhm I am confused, there are no anonymous types used in either code snippet! :confused:

      Regards, Nish


      Latest article: Code Project Posts Analyzer for Windows Phone 7 My technology blog: voidnish.wordpress.com

      OriginalGriffO S L 3 Replies Last reply
      0
      • OriginalGriffO OriginalGriff

        I decided it was time I read up on LINQ: never really used it, time I learnt. So, I have a quick look for a book. Amazon: Sams LINQ Unleashed for C#. Lets have a quick look "Surprise me" "check out Wikipedia; Wikipedia is wicked cool at providing detailed facts" Hmmm. Wicked cool? And a code fragment to illustrate how wonderfull anonymous types are:

               var request = HttpWebRequest.Create(string.Format(url, stock));
                using (var response = request.GetResponse())
                    {
                    using (var reader = new StreamReader(response.GetResponseStream(), Encoding.ASCII))
                        {
                        return (reader.ReadToEnd());
                        }
                    }
        

        I hate that. Why use an example where it is actually clearer if you don't use anonymous types?

                WebRequest request = HttpWebRequest.Create(string.Format(url, stock));
                using (WebResponse response = request.GetResponse())
                    {
                    using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.ASCII))
                        {
                        return (reader.ReadToEnd());
                        }
                    }
        

        Don't think I'll buy that one...

        Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."

        N Offline
        N Offline
        Nagy Vilmos
        wrote on last edited by
        #3

        Wicked? Cool? Sounds like someone needs a shot of boottoheadanol.


        Panic, Chaos, Destruction. My work here is done. or "Drink. Get drunk. Fall over." - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre

        1 Reply Last reply
        0
        • N Nish Nishant

          Uhm I am confused, there are no anonymous types used in either code snippet! :confused:

          Regards, Nish


          Latest article: Code Project Posts Analyzer for Windows Phone 7 My technology blog: voidnish.wordpress.com

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          Technically the use of "var" in the first example makes it an anonymous type, albeit a simplistic one. Cr@p example though.

          Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          N A 2 Replies Last reply
          0
          • N Nish Nishant

            Uhm I am confused, there are no anonymous types used in either code snippet! :confused:

            Regards, Nish


            Latest article: Code Project Posts Analyzer for Windows Phone 7 My technology blog: voidnish.wordpress.com

            S Offline
            S Offline
            S Senthil Kumar
            wrote on last edited by
            #5

            I'm guessing he meant the var keyword.

            Regards Senthil _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro

            N 1 Reply Last reply
            0
            • OriginalGriffO OriginalGriff

              Technically the use of "var" in the first example makes it an anonymous type, albeit a simplistic one. Cr@p example though.

              Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."

              N Offline
              N Offline
              Nish Nishant
              wrote on last edited by
              #6

              OriginalGriff wrote:

              Technically the use of "var" in the first example makes it an anonymous type, albeit a simplistic one.

              Well in this case the var is just an implicitly typed shortcut and the type is known at compile time. I would not call this an anonymous type at all. But I get what you mean.

              Regards, Nish


              Latest article: Code Project Posts Analyzer for Windows Phone 7 My technology blog: voidnish.wordpress.com

              S 1 Reply Last reply
              0
              • S S Senthil Kumar

                I'm guessing he meant the var keyword.

                Regards Senthil _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro

                N Offline
                N Offline
                Nish Nishant
                wrote on last edited by
                #7

                Yeah, apparently. But if the book used that snippet as an example of an anonymous type, that's quite concerning in my opinion :-)

                Regards, Nish


                Latest article: Code Project Posts Analyzer for Windows Phone 7 My technology blog: voidnish.wordpress.com

                1 Reply Last reply
                0
                • OriginalGriffO OriginalGriff

                  Technically the use of "var" in the first example makes it an anonymous type, albeit a simplistic one. Cr@p example though.

                  Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."

                  A Offline
                  A Offline
                  Abhinav S
                  wrote on last edited by
                  #8

                  OriginalGriff wrote:

                  Technically the use of "var" in the first example makes it an anonymous type

                  Nope. It makes the varible implicity typed i.e. the variable knows nothing about what it will be until the code compiles. A var need not always be neccesarily attached with annonymous types. E.g.

                  string[] words = { "apple", "strawberry", "grape", "peach", "banana" };
                  var wordQuery = from word in words
                  where word[0] == 'g'
                  select word;

                  Here we already know wordQuery is going to be of type IEnumerable and var need not be used. IEnumerable wordQuery will work just as well. 1. Apologies for posting code here but I could'nt help it. 2. Thanks for making me do some reading on this. 3. As Nish said, I see what you mean here. But I had to post this, I had to. :)

                  N S N OriginalGriffO 4 Replies Last reply
                  0
                  • A Abhinav S

                    OriginalGriff wrote:

                    Technically the use of "var" in the first example makes it an anonymous type

                    Nope. It makes the varible implicity typed i.e. the variable knows nothing about what it will be until the code compiles. A var need not always be neccesarily attached with annonymous types. E.g.

                    string[] words = { "apple", "strawberry", "grape", "peach", "banana" };
                    var wordQuery = from word in words
                    where word[0] == 'g'
                    select word;

                    Here we already know wordQuery is going to be of type IEnumerable and var need not be used. IEnumerable wordQuery will work just as well. 1. Apologies for posting code here but I could'nt help it. 2. Thanks for making me do some reading on this. 3. As Nish said, I see what you mean here. But I had to post this, I had to. :)

                    N Offline
                    N Offline
                    Nish Nishant
                    wrote on last edited by
                    #9

                    Abhinav S wrote:

                    It makes the varible implicity typed i.e. the variable knows nothing about what it will be until the code exectues.

                    That's not fully correct. The variable type is known at compile time. It just saves you some typing :-)

                    Regards, Nish


                    Latest article: Code Project Posts Analyzer for Windows Phone 7 My technology blog: voidnish.wordpress.com

                    A M F 3 Replies Last reply
                    0
                    • A Abhinav S

                      OriginalGriff wrote:

                      Technically the use of "var" in the first example makes it an anonymous type

                      Nope. It makes the varible implicity typed i.e. the variable knows nothing about what it will be until the code compiles. A var need not always be neccesarily attached with annonymous types. E.g.

                      string[] words = { "apple", "strawberry", "grape", "peach", "banana" };
                      var wordQuery = from word in words
                      where word[0] == 'g'
                      select word;

                      Here we already know wordQuery is going to be of type IEnumerable and var need not be used. IEnumerable wordQuery will work just as well. 1. Apologies for posting code here but I could'nt help it. 2. Thanks for making me do some reading on this. 3. As Nish said, I see what you mean here. But I had to post this, I had to. :)

                      S Offline
                      S Offline
                      S Senthil Kumar
                      wrote on last edited by
                      #10

                      Abhinav S wrote:

                      the variable knows nothing about what it will be until the code exectues.

                      Well actually, the type is resolved at compile time. At runtime, there is no difference between explicit and implicit typing.

                      Regards Senthil _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro

                      1 Reply Last reply
                      0
                      • A Abhinav S

                        OriginalGriff wrote:

                        Technically the use of "var" in the first example makes it an anonymous type

                        Nope. It makes the varible implicity typed i.e. the variable knows nothing about what it will be until the code compiles. A var need not always be neccesarily attached with annonymous types. E.g.

                        string[] words = { "apple", "strawberry", "grape", "peach", "banana" };
                        var wordQuery = from word in words
                        where word[0] == 'g'
                        select word;

                        Here we already know wordQuery is going to be of type IEnumerable and var need not be used. IEnumerable wordQuery will work just as well. 1. Apologies for posting code here but I could'nt help it. 2. Thanks for making me do some reading on this. 3. As Nish said, I see what you mean here. But I had to post this, I had to. :)

                        N Offline
                        N Offline
                        Nagy Vilmos
                        wrote on last edited by
                        #11

                        Just because Griff MkI posts codes, there's no need to carry on the crime. Anyone would think this is a techn... ... oh, the shame, this is a technical site.


                        Panic, Chaos, Destruction. My work here is done. or "Drink. Get drunk. Fall over." - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre

                        N 1 Reply Last reply
                        0
                        • N Nagy Vilmos

                          Just because Griff MkI posts codes, there's no need to carry on the crime. Anyone would think this is a techn... ... oh, the shame, this is a technical site.


                          Panic, Chaos, Destruction. My work here is done. or "Drink. Get drunk. Fall over." - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre

                          N Offline
                          N Offline
                          Nish Nishant
                          wrote on last edited by
                          #12

                          Nagy Vilmos wrote:

                          ... oh, the shame, this is a technical site.

                          :laugh:

                          Regards, Nish


                          Latest article: Code Project Posts Analyzer for Windows Phone 7 My technology blog: voidnish.wordpress.com

                          1 Reply Last reply
                          0
                          • A Abhinav S

                            OriginalGriff wrote:

                            Technically the use of "var" in the first example makes it an anonymous type

                            Nope. It makes the varible implicity typed i.e. the variable knows nothing about what it will be until the code compiles. A var need not always be neccesarily attached with annonymous types. E.g.

                            string[] words = { "apple", "strawberry", "grape", "peach", "banana" };
                            var wordQuery = from word in words
                            where word[0] == 'g'
                            select word;

                            Here we already know wordQuery is going to be of type IEnumerable and var need not be used. IEnumerable wordQuery will work just as well. 1. Apologies for posting code here but I could'nt help it. 2. Thanks for making me do some reading on this. 3. As Nish said, I see what you mean here. But I had to post this, I had to. :)

                            OriginalGriffO Offline
                            OriginalGriffO Offline
                            OriginalGriff
                            wrote on last edited by
                            #13

                            :thumbsup: 5! I'm always open to correction. Especially when its stuff I'm trying to learn. Think I'll keep looking for a rather more accurate book. :sigh:

                            Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."

                            "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                            "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                            N 2 Replies Last reply
                            0
                            • N Nish Nishant

                              Abhinav S wrote:

                              It makes the varible implicity typed i.e. the variable knows nothing about what it will be until the code exectues.

                              That's not fully correct. The variable type is known at compile time. It just saves you some typing :-)

                              Regards, Nish


                              Latest article: Code Project Posts Analyzer for Windows Phone 7 My technology blog: voidnish.wordpress.com

                              A Offline
                              A Offline
                              Abhinav S
                              wrote on last edited by
                              #14

                              Fixed! :)

                              The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick

                              N 1 Reply Last reply
                              0
                              • OriginalGriffO OriginalGriff

                                :thumbsup: 5! I'm always open to correction. Especially when its stuff I'm trying to learn. Think I'll keep looking for a rather more accurate book. :sigh:

                                Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."

                                N Offline
                                N Offline
                                Nish Nishant
                                wrote on last edited by
                                #15

                                OriginalGriff wrote:

                                I'm always open to correction.

                                Abhinav was not 100% right. Please read the corrections to his correction too :-)

                                Regards, Nish


                                Latest article: Code Project Posts Analyzer for Windows Phone 7 My technology blog: voidnish.wordpress.com

                                A 1 Reply Last reply
                                0
                                • A Abhinav S

                                  Fixed! :)

                                  The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick

                                  N Offline
                                  N Offline
                                  Nish Nishant
                                  wrote on last edited by
                                  #16

                                  Thank you.

                                  Regards, Nish


                                  Latest article: Code Project Posts Analyzer for Windows Phone 7 My technology blog: voidnish.wordpress.com

                                  1 Reply Last reply
                                  0
                                  • OriginalGriffO OriginalGriff

                                    :thumbsup: 5! I'm always open to correction. Especially when its stuff I'm trying to learn. Think I'll keep looking for a rather more accurate book. :sigh:

                                    Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."

                                    N Offline
                                    N Offline
                                    Nish Nishant
                                    wrote on last edited by
                                    #17

                                    Well he fixed his post, so it's all good now :-)

                                    Regards, Nish


                                    Latest article: Code Project Posts Analyzer for Windows Phone 7 My technology blog: voidnish.wordpress.com

                                    1 Reply Last reply
                                    0
                                    • N Nish Nishant

                                      OriginalGriff wrote:

                                      I'm always open to correction.

                                      Abhinav was not 100% right. Please read the corrections to his correction too :-)

                                      Regards, Nish


                                      Latest article: Code Project Posts Analyzer for Windows Phone 7 My technology blog: voidnish.wordpress.com

                                      A Offline
                                      A Offline
                                      Abhinav S
                                      wrote on last edited by
                                      #18

                                      Nishant Sivakumar wrote:

                                      Abhinav was not 100% right. Please read the corrections to his correction too

                                      I need a beer... :)

                                      The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick

                                      N N 2 Replies Last reply
                                      0
                                      • A Abhinav S

                                        Nishant Sivakumar wrote:

                                        Abhinav was not 100% right. Please read the corrections to his correction too

                                        I need a beer... :)

                                        The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick

                                        N Offline
                                        N Offline
                                        Nish Nishant
                                        wrote on last edited by
                                        #19

                                        Thanks again for fixing it :-) You don't want newbies who may encounter it in future to go away with wrong info. Good work! :thumbsup:

                                        Regards, Nish


                                        Latest article: Code Project Posts Analyzer for Windows Phone 7 My technology blog: voidnish.wordpress.com

                                        A 1 Reply Last reply
                                        0
                                        • N Nish Nishant

                                          Thanks again for fixing it :-) You don't want newbies who may encounter it in future to go away with wrong info. Good work! :thumbsup:

                                          Regards, Nish


                                          Latest article: Code Project Posts Analyzer for Windows Phone 7 My technology blog: voidnish.wordpress.com

                                          A Offline
                                          A Offline
                                          Abhinav S
                                          wrote on last edited by
                                          #20

                                          Nishant Sivakumar wrote:

                                          You don't want newbies who may encounter it in future to go away with wrong info

                                          Good point.

                                          The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.

                                          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