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. General Programming
  3. C#
  4. Automatic Properties

Automatic Properties

Scheduled Pinned Locked Moved C#
question
8 Posts 6 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.
  • G Offline
    G Offline
    GChannon
    wrote on last edited by
    #1

    Hi, If you use an automatic property and want to reference it within the same class I assume you would specify the property but if you had another property within the same class that required validation you would reference the field. Don't you think this is messy code? private string _firstName; public string FirstName { get { return _firstName; } set { _firstName = value; } } public string LastName { get; set; } public void Foo() { string test = _firstName + LastName; }

    modified on Thursday, March 6, 2008 5:29 AM

    T R P 3 Replies Last reply
    0
    • G GChannon

      Hi, If you use an automatic property and want to reference it within the same class I assume you would specify the property but if you had another property within the same class that required validation you would reference the field. Don't you think this is messy code? private string _firstName; public string FirstName { get { return _firstName; } set { _firstName = value; } } public string LastName { get; set; } public void Foo() { string test = _firstName + LastName; }

      modified on Thursday, March 6, 2008 5:29 AM

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      tell me, is the following so hard to understand :

      Please do not post programming questions here

      moreover, you were already been told so in one of your previous questions XLINQ. so, no excuse man :zzz:

      [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

      1 Reply Last reply
      0
      • G GChannon

        Hi, If you use an automatic property and want to reference it within the same class I assume you would specify the property but if you had another property within the same class that required validation you would reference the field. Don't you think this is messy code? private string _firstName; public string FirstName { get { return _firstName; } set { _firstName = value; } } public string LastName { get; set; } public void Foo() { string test = _firstName + LastName; }

        modified on Thursday, March 6, 2008 5:29 AM

        R Offline
        R Offline
        Rajesh R Subramanian
        wrote on last edited by
        #3

        On 15th Dec 2007 you were told not to post programming questions[^] in the Lounge.

        Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

        G V N 3 Replies Last reply
        0
        • R Rajesh R Subramanian

          On 15th Dec 2007 you were told not to post programming questions[^] in the Lounge.

          Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

          G Offline
          G Offline
          GChannon
          wrote on last edited by
          #4

          Please forgive me! I apologies for innocently posting a programming related question in the wrong forum on a programming website. :(( :(( :(( :(( :(( :(( :((

          V 1 Reply Last reply
          0
          • R Rajesh R Subramanian

            On 15th Dec 2007 you were told not to post programming questions[^] in the Lounge.

            Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

            V Offline
            V Offline
            Vasudevan Deepak Kumar
            wrote on last edited by
            #5

            Rajesh R Subramanian wrote:

            15th Dec 2007

            That was on 15th December 2007. Today is not 15th December 2007. Today it is 6th March 2008. Your system clock is very slow. You may need to replace your CMOS.

            Vasudevan Deepak Kumar Personal Homepage
            Tech Gossips
            A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson

            1 Reply Last reply
            0
            • G GChannon

              Please forgive me! I apologies for innocently posting a programming related question in the wrong forum on a programming website. :(( :(( :(( :(( :(( :(( :((

              V Offline
              V Offline
              Vasudevan Deepak Kumar
              wrote on last edited by
              #6

              GChannon wrote:

              innocently

              How do you trip down so frequently? Assume you are elecrocuted today accidentally by stamping over a live electric wire. Ten days down the line, would'nt you be more careful when you are repairing an electric appliance?

              Vasudevan Deepak Kumar Personal Homepage
              Tech Gossips
              A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson

              1 Reply Last reply
              0
              • R Rajesh R Subramanian

                On 15th Dec 2007 you were told not to post programming questions[^] in the Lounge.

                Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

                N Offline
                N Offline
                NormDroid
                wrote on last edited by
                #7

                Is it a programming question or is he asking programming preference.

                Brainware Error - reboot required.

                1 Reply Last reply
                0
                • G GChannon

                  Hi, If you use an automatic property and want to reference it within the same class I assume you would specify the property but if you had another property within the same class that required validation you would reference the field. Don't you think this is messy code? private string _firstName; public string FirstName { get { return _firstName; } set { _firstName = value; } } public string LastName { get; set; } public void Foo() { string test = _firstName + LastName; }

                  modified on Thursday, March 6, 2008 5:29 AM

                  P Offline
                  P Offline
                  Pete OHanlon
                  wrote on last edited by
                  #8

                  Anonymous properties are a convenience. Don't abuse them - be consistent with your approach to them.

                  Deja View - the feeling that you've seen this post before.

                  My blog | My articles

                  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