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. An interesting (or not) thing about C#'s var

An interesting (or not) thing about C#'s var

Scheduled Pinned Locked Moved The Lounge
csharppythonvisual-studiocomfunctional
43 Posts 12 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.
  • Richard DeemingR Richard Deeming

    John Simmons / outlaw programmer wrote:

    Why bother even defining types at all?

    Because var doesn't mean "untyped". It means, "the type of this variable is obvious to the compiler, so I don't need to bother writing it".


    "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

    J Offline
    J Offline
    Jeremy Falcon
    wrote on last edited by
    #41

    Bingo!

    Jeremy Falcon

    1 Reply Last reply
    0
    • realJSOPR realJSOP

      I don't like var. If it's so goddamn wonderful, why require its use at all? Why bother even defining types at all? If I wanted to code like that, I'd use VB.

      ".45 ACP - because shooting twice is just silly" - JSOP, 2010
      -----
      You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
      -----
      When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

      J Offline
      J Offline
      Jeremy Falcon
      wrote on last edited by
      #42

      Don't confuse var with dynamic.

      Jeremy Falcon

      1 Reply Last reply
      0
      • J Jeremy Falcon

        Trust me, I've already learned that N_tro_P simply does nothing but call everyone stupid and argues. You can't win with someone on a podium thinking he's better than everyone. For what it's worth, I'm very pro var and I still agree with your points. I'll still use var personally, but I still agree with your points. So rest assured, there are pro var people out there that do listen. :-D

        Jeremy Falcon

        Sander RosselS Offline
        Sander RosselS Offline
        Sander Rossel
        wrote on last edited by
        #43

        Ahhh... The sound of reason, I've missed it in these parts :D I'm not pro-var and not anti-var, not sure how var I'll go :D

        Read my (free) ebook Object-Oriented Programming in C# Succinctly. Visit my blog at Sander's bits - Writing the code you need. Or read my articles here on CodeProject.

        Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

        Regards, Sander

        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