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. Poor var (C#)

Poor var (C#)

Scheduled Pinned Locked Moved The Lounge
csharpc++comdiscussion
62 Posts 36 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.
  • N Nish Nishant

    If you look at this week's poll forum, you can see some pretty nasty comments about the C# var keyword. People seem to have mistaken it to be equivalent to the VB6/COM VARIANT data type. A closer equivalent to the VB6/COM VARIANT would be C# 4.0's dynamic keyword. But to attack var based on some wrong assumptions is sad. Remember, all's fair in love and var ;P

    Regards, Nish


    Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
    My latest book : C++/CLI in Action / Amazon.com link

    M Offline
    M Offline
    Marc Clifton
    wrote on last edited by
    #3

    I have a "why var sucks" article in mind. It'll be quite amusing. Marc

    Will work for food. Interacx

    I'm not overthinking the problem, I just felt like I needed a small, unimportant, uninteresting rant! - Martin Hart Turner

    T 1 Reply Last reply
    0
    • N Nish Nishant

      If you look at this week's poll forum, you can see some pretty nasty comments about the C# var keyword. People seem to have mistaken it to be equivalent to the VB6/COM VARIANT data type. A closer equivalent to the VB6/COM VARIANT would be C# 4.0's dynamic keyword. But to attack var based on some wrong assumptions is sad. Remember, all's fair in love and var ;P

      Regards, Nish


      Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
      My latest book : C++/CLI in Action / Amazon.com link

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #4

      I think calling anything "var" is a bad naming convention, that name has way too much baggage.

      P 1 Reply Last reply
      0
      • N Nish Nishant

        If you look at this week's poll forum, you can see some pretty nasty comments about the C# var keyword. People seem to have mistaken it to be equivalent to the VB6/COM VARIANT data type. A closer equivalent to the VB6/COM VARIANT would be C# 4.0's dynamic keyword. But to attack var based on some wrong assumptions is sad. Remember, all's fair in love and var ;P

        Regards, Nish


        Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
        My latest book : C++/CLI in Action / Amazon.com link

        M Offline
        M Offline
        M dHatter
        wrote on last edited by
        #5

        why not just call it object instead lol

        "I do not know with what weapons World War 3 will be fought, but World War 4 will be fought with sticks and stones." Einstein "Few things are harder to put up with than the annoyance of a good example." Mark Twain

        P 1 Reply Last reply
        0
        • M M dHatter

          why not just call it object instead lol

          "I do not know with what weapons World War 3 will be fought, but World War 4 will be fought with sticks and stones." Einstein "Few things are harder to put up with than the annoyance of a good example." Mark Twain

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #6

          Hmmm... what if object had worked like var to begin with? :suss:

          A A 2 Replies Last reply
          0
          • N Nish Nishant

            If you look at this week's poll forum, you can see some pretty nasty comments about the C# var keyword. People seem to have mistaken it to be equivalent to the VB6/COM VARIANT data type. A closer equivalent to the VB6/COM VARIANT would be C# 4.0's dynamic keyword. But to attack var based on some wrong assumptions is sad. Remember, all's fair in love and var ;P

            Regards, Nish


            Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
            My latest book : C++/CLI in Action / Amazon.com link

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #7

            It is a var, var better thing I do, than I have ever done; it is a var, var better rest I go to, than I have ever known.

            ___________________________________________ .\\axxx (That's an 'M')

            B 1 Reply Last reply
            0
            • N Nish Nishant

              If you look at this week's poll forum, you can see some pretty nasty comments about the C# var keyword. People seem to have mistaken it to be equivalent to the VB6/COM VARIANT data type. A closer equivalent to the VB6/COM VARIANT would be C# 4.0's dynamic keyword. But to attack var based on some wrong assumptions is sad. Remember, all's fair in love and var ;P

              Regards, Nish


              Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
              My latest book : C++/CLI in Action / Amazon.com link

              A Offline
              A Offline
              Adam Maras
              wrote on last edited by
              #8

              Nishant Sivakumar wrote:

              Remember, all's fair in love and var ;P

              You just earned my 5 :laugh:

              Adam Maras | Software Developer Microsoft Certified Professional Developer

              1 Reply Last reply
              0
              • N Nish Nishant

                If you look at this week's poll forum, you can see some pretty nasty comments about the C# var keyword. People seem to have mistaken it to be equivalent to the VB6/COM VARIANT data type. A closer equivalent to the VB6/COM VARIANT would be C# 4.0's dynamic keyword. But to attack var based on some wrong assumptions is sad. Remember, all's fair in love and var ;P

                Regards, Nish


                Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
                My latest book : C++/CLI in Action / Amazon.com link

                B Offline
                B Offline
                BillWoodruff
                wrote on last edited by
                #9

                (Namaste, Namaskaram, or Vanakkum : your choice :) Sri Nishant, I understand the "Committee for the Defense of Var," with a war-chest of millions of dollars provided by the VB party, in collusion with strident libertarians protesting strongly-typed languages, fed by a network of radio-show hosts with legions of fanatic followers ... is even now launching a campaign to use this sneaky trojan-horse of "var" as just the launching pad for the total dismantling of pure, reformed, C#. Sinister forces in the industrial-military complex, the webs of former government officials who left their jobs with regulatory bodies in government to turn around and become lobbyists for the companies they once regulated ... at enormous salaries ... they are all in on the plan to dilute the vital fluids of young programmers, making them weakly-typed. Even now the "Var" poster-child's poster : a picture of a ten-year old female hacker, with the face of an angel, whose hands are permanently crippled from typing long object-inheritance declarations twice on the same line, are going up in shopping malls and latterias across the country bearing the slogan "With Var She would still be able to type !" It is time for us to forget our minor quibbles about "polymorphism," and unite to combat this insidious threat to our ritual purity. When our enemies are not "bound" by our ethics, surely we are righteous to fight them back without respect for what they claim to be their ethics ! best, Bill

                "Many : not conversant with mathematical studies, imagine that because it [the Analytical Engine] is to give results in numerical notation, its processes must consequently be arithmetical, numerical, rather than algebraical and analytical. This is an error. The engine can arrange and combine numerical quantities as if they were letters or any other general symbols; and it fact it might bring out its results in algebraical notation, were provisions made accordingly." Ada, Countess Lovelace, 1844

                D K 2 Replies Last reply
                0
                • N Nish Nishant

                  If you look at this week's poll forum, you can see some pretty nasty comments about the C# var keyword. People seem to have mistaken it to be equivalent to the VB6/COM VARIANT data type. A closer equivalent to the VB6/COM VARIANT would be C# 4.0's dynamic keyword. But to attack var based on some wrong assumptions is sad. Remember, all's fair in love and var ;P

                  Regards, Nish


                  Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
                  My latest book : C++/CLI in Action / Amazon.com link

                  R Offline
                  R Offline
                  Rei Miyasaka
                  wrote on last edited by
                  #10

                  I remember Sun insisting at conferences several years ago that the unsafe keyword in C# would be its downfall. People are idiots.

                  D 1 Reply Last reply
                  0
                  • M Marc Clifton

                    I have a "why var sucks" article in mind. It'll be quite amusing. Marc

                    Will work for food. Interacx

                    I'm not overthinking the problem, I just felt like I needed a small, unimportant, uninteresting rant! - Martin Hart Turner

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

                    I'll want you to explain me what you would use for a linq query that returns an anonymous type, or what is not enough strongly typed for you in the code var records = new List(); For me, var is a blessing. It saves me of repeating redundant information (why the hell would I want to say in the left AND the right hand side that this is a damned List of Records?).

                    G A H A C 7 Replies Last reply
                    0
                    • N Nish Nishant

                      If you look at this week's poll forum, you can see some pretty nasty comments about the C# var keyword. People seem to have mistaken it to be equivalent to the VB6/COM VARIANT data type. A closer equivalent to the VB6/COM VARIANT would be C# 4.0's dynamic keyword. But to attack var based on some wrong assumptions is sad. Remember, all's fair in love and var ;P

                      Regards, Nish


                      Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
                      My latest book : C++/CLI in Action / Amazon.com link

                      M Offline
                      M Offline
                      Mark_Wallace
                      wrote on last edited by
                      #12

                      Nishant Sivakumar wrote:

                      to attack var something is not understood, based on some wrong assumptions, is sad the norm.

                      IFYPFY

                      I wanna be a eunuchs developer! Pass me a bread knife!

                      1 Reply Last reply
                      0
                      • T tec goblin

                        I'll want you to explain me what you would use for a linq query that returns an anonymous type, or what is not enough strongly typed for you in the code var records = new List(); For me, var is a blessing. It saves me of repeating redundant information (why the hell would I want to say in the left AND the right hand side that this is a damned List of Records?).

                        G Offline
                        G Offline
                        Guy Harwood
                        wrote on last edited by
                        #13

                        my sentiments exactly. i use var all the time now.

                        ---Guy H ;-)---

                        1 Reply Last reply
                        0
                        • T tec goblin

                          I'll want you to explain me what you would use for a linq query that returns an anonymous type, or what is not enough strongly typed for you in the code var records = new List(); For me, var is a blessing. It saves me of repeating redundant information (why the hell would I want to say in the left AND the right hand side that this is a damned List of Records?).

                          A Offline
                          A Offline
                          AspDotNetDev
                          wrote on last edited by
                          #14

                          Yeah, this should have been thought of way long ago. Makes one wonder if any other languages have this feature.

                          P D 2 Replies Last reply
                          0
                          • B BillWoodruff

                            (Namaste, Namaskaram, or Vanakkum : your choice :) Sri Nishant, I understand the "Committee for the Defense of Var," with a war-chest of millions of dollars provided by the VB party, in collusion with strident libertarians protesting strongly-typed languages, fed by a network of radio-show hosts with legions of fanatic followers ... is even now launching a campaign to use this sneaky trojan-horse of "var" as just the launching pad for the total dismantling of pure, reformed, C#. Sinister forces in the industrial-military complex, the webs of former government officials who left their jobs with regulatory bodies in government to turn around and become lobbyists for the companies they once regulated ... at enormous salaries ... they are all in on the plan to dilute the vital fluids of young programmers, making them weakly-typed. Even now the "Var" poster-child's poster : a picture of a ten-year old female hacker, with the face of an angel, whose hands are permanently crippled from typing long object-inheritance declarations twice on the same line, are going up in shopping malls and latterias across the country bearing the slogan "With Var She would still be able to type !" It is time for us to forget our minor quibbles about "polymorphism," and unite to combat this insidious threat to our ritual purity. When our enemies are not "bound" by our ethics, surely we are righteous to fight them back without respect for what they claim to be their ethics ! best, Bill

                            "Many : not conversant with mathematical studies, imagine that because it [the Analytical Engine] is to give results in numerical notation, its processes must consequently be arithmetical, numerical, rather than algebraical and analytical. This is an error. The engine can arrange and combine numerical quantities as if they were letters or any other general symbols; and it fact it might bring out its results in algebraical notation, were provisions made accordingly." Ada, Countess Lovelace, 1844

                            D Offline
                            D Offline
                            dazfuller
                            wrote on last edited by
                            #15

                            var was just a stepping stone to the dynamic keyword, that little poster-child may have crippled hands but she has an evil smile.

                            1 Reply Last reply
                            0
                            • T tec goblin

                              I'll want you to explain me what you would use for a linq query that returns an anonymous type, or what is not enough strongly typed for you in the code var records = new List(); For me, var is a blessing. It saves me of repeating redundant information (why the hell would I want to say in the left AND the right hand side that this is a damned List of Records?).

                              H Offline
                              H Offline
                              hairy_hats
                              wrote on last edited by
                              #16

                              Possibly because if you want to find a List variable in a long list of declarations, it's much easier to run your eye down a vertical line of types on the left hand side of the = than to have to scan left and right on each line to find the declaration type. var for Linq queries I can see the value of, var for every declaration is confusing.

                              I hope you realise that hamsters are very creative when it comes to revenge. - Elaine

                              B S T 3 Replies Last reply
                              0
                              • N Nish Nishant

                                If you look at this week's poll forum, you can see some pretty nasty comments about the C# var keyword. People seem to have mistaken it to be equivalent to the VB6/COM VARIANT data type. A closer equivalent to the VB6/COM VARIANT would be C# 4.0's dynamic keyword. But to attack var based on some wrong assumptions is sad. Remember, all's fair in love and var ;P

                                Regards, Nish


                                Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
                                My latest book : C++/CLI in Action / Amazon.com link

                                B Offline
                                B Offline
                                Brady Kelly
                                wrote on last edited by
                                #17

                                I was at a DevDays lecture when 'var' was introduced to the audience. I had a phat laugh at all the self-important 'experts' whose disparaging comments you could hear flying around the audience. The sounded like a bunch of church elders would on hearing one of their members had had his ear pierced.

                                1 Reply Last reply
                                0
                                • H hairy_hats

                                  Possibly because if you want to find a List variable in a long list of declarations, it's much easier to run your eye down a vertical line of types on the left hand side of the = than to have to scan left and right on each line to find the declaration type. var for Linq queries I can see the value of, var for every declaration is confusing.

                                  I hope you realise that hamsters are very creative when it comes to revenge. - Elaine

                                  B Offline
                                  B Offline
                                  Brady Kelly
                                  wrote on last edited by
                                  #18

                                  How about looking for the variable name that should indicate it being a list, or do you declare List v1 = new List();? I would quickly scan down my list and find var studentList = new List();

                                  H A L N 4 Replies Last reply
                                  0
                                  • L Lost User

                                    It is a var, var better thing I do, than I have ever done; it is a var, var better rest I go to, than I have ever known.

                                    ___________________________________________ .\\axxx (That's an 'M')

                                    B Offline
                                    B Offline
                                    Brady Kelly
                                    wrote on last edited by
                                    #19

                                    _Maxxx_ wrote:

                                    It is a var, var better thing I do, than I have ever done; it is a var, var better rest I go to, than I have ever knownthrown.

                                    FTFY :)

                                    1 Reply Last reply
                                    0
                                    • B Brady Kelly

                                      How about looking for the variable name that should indicate it being a list, or do you declare List v1 = new List();? I would quickly scan down my list and find var studentList = new List();

                                      H Offline
                                      H Offline
                                      hairy_hats
                                      wrote on last edited by
                                      #20

                                      Maybe we could stick to the status quo but enforce column alignments à la Fortran to make all this scanning easier? ;)

                                      I hope you realise that hamsters are very creative when it comes to revenge. - Elaine

                                      B G 2 Replies Last reply
                                      0
                                      • H hairy_hats

                                        Possibly because if you want to find a List variable in a long list of declarations, it's much easier to run your eye down a vertical line of types on the left hand side of the = than to have to scan left and right on each line to find the declaration type. var for Linq queries I can see the value of, var for every declaration is confusing.

                                        I hope you realise that hamsters are very creative when it comes to revenge. - Elaine

                                        S Offline
                                        S Offline
                                        Simon Pickersgill
                                        wrote on last edited by
                                        #21

                                        Ctrl + F

                                        1 Reply Last reply
                                        0
                                        • H hairy_hats

                                          Maybe we could stick to the status quo but enforce column alignments à la Fortran to make all this scanning easier? ;)

                                          I hope you realise that hamsters are very creative when it comes to revenge. - Elaine

                                          B Offline
                                          B Offline
                                          Brady Kelly
                                          wrote on last edited by
                                          #22

                                          I once built a column aligning editor for a COBOL project. Impressed my cute team mate quite a bit, where others were all using notepad and counting columns, ours had tab settings at all the right columns. :)

                                          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