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. Other Discussions
  3. Clever Code
  4. Hidden Features of C#

Hidden Features of C#

Scheduled Pinned Locked Moved Clever Code
csharpcomquestion
25 Posts 15 Posters 8 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 GenJerDan

    Yes, but no one reads the documentation. After attempting to find something relevent 17 times, we've all given up.

    K Offline
    K Offline
    Kevin Drzycimski
    wrote on last edited by
    #5

    well seriously, you should read this book http://blog.oncode.info/wp-content/uploads/2008/02/rtfm.png[^] perhaps you didn't read well, because after 17 iterations you should have your relevant information, if not, read it 17 times again

    G 1 Reply Last reply
    0
    • K Kevin Drzycimski

      well seriously, you should read this book http://blog.oncode.info/wp-content/uploads/2008/02/rtfm.png[^] perhaps you didn't read well, because after 17 iterations you should have your relevant information, if not, read it 17 times again

      G Offline
      G Offline
      GenJerDan
      wrote on last edited by
      #6

      Ja, und hinterher ein Nasenbär und keiner weiss warum. ;P

      K 1 Reply Last reply
      0
      • G GenJerDan

        Ja, und hinterher ein Nasenbär und keiner weiss warum. ;P

        K Offline
        K Offline
        Kevin Drzycimski
        wrote on last edited by
        #7

        GenJerDan wrote:

        Ja, und hinterher ein Nasenbär und keiner weiss warum.

        oh, der kam unerwartet. aber werde ich mir merken :-D

        G S 2 Replies Last reply
        0
        • K Kevin Drzycimski

          GenJerDan wrote:

          Ja, und hinterher ein Nasenbär und keiner weiss warum.

          oh, der kam unerwartet. aber werde ich mir merken :-D

          G Offline
          G Offline
          GenJerDan
          wrote on last edited by
          #8

          :~ :laugh:

          1 Reply Last reply
          0
          • K Kanasz Robert

            Hi, this is not a hidden feature. This feature is documented ;)

            S Offline
            S Offline
            SalarSoft
            wrote on last edited by
            #9

            I know, actually this is title of stackoverflow topic! There are keywords that are not documented.

            R 1 Reply Last reply
            0
            • K Kevin Drzycimski

              sorry, but if you look at the MSDN C# Reference http://msdn.microsoft.com/en-us/library/618ayhy6.aspx[^] and hit C# Operators you can see them at glance. Looks like there is some RTFM to do :-D

              S Offline
              S Offline
              SalarSoft
              wrote on last edited by
              #10

              RTFM is done for C#2 and upgraded for C#3 and 4, but still seems I missed some features during upgrade! it happens ;P

              T 1 Reply Last reply
              0
              • S SalarSoft

                I know, actually this is title of stackoverflow topic! There are keywords that are not documented.

                R Offline
                R Offline
                riced
                wrote on last edited by
                #11

                SalarSoft wrote:

                There are keywords that are not documented.

                Tried reading the language specs? That documents them. I had a quick look at the StackOverflow link - if these are hidden features they can't have been looking at anything beyond C# in 5 :laugh: minutes.

                Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis The only valid measurement of code quality: WTFs/minute.

                K 1 Reply Last reply
                0
                • S SalarSoft

                  Hidden Features of C# Personally I like ?? operator and started using it since then:

                  private IList<Foo> _foo;

                  public IList<Foo> ListOfFoo
                  { get { return _foo ?? (_foo = new List<Foo>()); } }

                  C Offline
                  C Offline
                  Chris Maunder
                  wrote on last edited by
                  #12

                  Hidden? You have to be kidding me. Each iteration of C# has been preceeded with a barrage of evangalism and education, and to be unaware of things such as "as" can only mean one has had one's head firmly buried in the sand. readonly? hidden? :doh:

                  cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                  S A 2 Replies Last reply
                  0
                  • C Chris Maunder

                    Hidden? You have to be kidding me. Each iteration of C# has been preceeded with a barrage of evangalism and education, and to be unaware of things such as "as" can only mean one has had one's head firmly buried in the sand. readonly? hidden? :doh:

                    cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                    S Offline
                    S Offline
                    SalarSoft
                    wrote on last edited by
                    #13

                    Actually I just copied the stackoverflow title! have you guys noticed __makeref ? http://stackoverflow.com/questions/9033/hidden-features-of-c/9125#9125[^] more info: http://www.eggheadcafe.com/articles/20030114.asp[^] There are good tricks too. Worth reading that, but should I change this topic title?!

                    1 Reply Last reply
                    0
                    • C Chris Maunder

                      Hidden? You have to be kidding me. Each iteration of C# has been preceeded with a barrage of evangalism and education, and to be unaware of things such as "as" can only mean one has had one's head firmly buried in the sand. readonly? hidden? :doh:

                      cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

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

                      Actually, it does seem very obscure. Much like this operator I stumbled upon the other day:

                      int x = 5 + 1;

                      Much to my surprise, this operator actually performs TWO distinct operations, depending on context!

                      string x = "5" + "1";

                      My God! An operator that BOTH adds integers AND concatenates strings. I believe it even works on non integral types. Truly a Jack of all trades! Disclaimer: this post is a joke.

                      [Forum Guidelines]

                      F C 2 Replies Last reply
                      0
                      • A AspDotNetDev

                        Actually, it does seem very obscure. Much like this operator I stumbled upon the other day:

                        int x = 5 + 1;

                        Much to my surprise, this operator actually performs TWO distinct operations, depending on context!

                        string x = "5" + "1";

                        My God! An operator that BOTH adds integers AND concatenates strings. I believe it even works on non integral types. Truly a Jack of all trades! Disclaimer: this post is a joke.

                        [Forum Guidelines]

                        F Offline
                        F Offline
                        fjdiewornncalwe
                        wrote on last edited by
                        #15

                        Do I sense some sarcasm... :)

                        I wasn't, now I am, then I won't be anymore.

                        A 1 Reply Last reply
                        0
                        • F fjdiewornncalwe

                          Do I sense some sarcasm... :)

                          I wasn't, now I am, then I won't be anymore.

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

                          I hope so! ;)

                          [Forum Guidelines]

                          1 Reply Last reply
                          0
                          • A AspDotNetDev

                            Actually, it does seem very obscure. Much like this operator I stumbled upon the other day:

                            int x = 5 + 1;

                            Much to my surprise, this operator actually performs TWO distinct operations, depending on context!

                            string x = "5" + "1";

                            My God! An operator that BOTH adds integers AND concatenates strings. I believe it even works on non integral types. Truly a Jack of all trades! Disclaimer: this post is a joke.

                            [Forum Guidelines]

                            C Offline
                            C Offline
                            Chris Meech
                            wrote on last edited by
                            #17

                            It's a good thing it's obscure, because the second use gives a result of 51 when the correct answer is 6. ;)

                            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] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]

                            A 1 Reply Last reply
                            0
                            • C Chris Meech

                              It's a good thing it's obscure, because the second use gives a result of 51 when the correct answer is 6. ;)

                              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] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]

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

                              Chris Meech wrote:

                              the second use gives a result of 51 when the correct answer is 6

                              Aw noo! I must go back and correct all teh codez for my area summation algorithm! I don't want my boss to see this mistake... time for an area 51 cover-up.

                              [Forum Guidelines]

                              1 Reply Last reply
                              0
                              • K Kevin Drzycimski

                                GenJerDan wrote:

                                Ja, und hinterher ein Nasenbär und keiner weiss warum.

                                oh, der kam unerwartet. aber werde ich mir merken :-D

                                S Offline
                                S Offline
                                swatadas
                                wrote on last edited by
                                #19

                                :laugh:

                                1 Reply Last reply
                                0
                                • S SalarSoft

                                  Hidden Features of C# Personally I like ?? operator and started using it since then:

                                  private IList<Foo> _foo;

                                  public IList<Foo> ListOfFoo
                                  { get { return _foo ?? (_foo = new List<Foo>()); } }

                                  M Offline
                                  M Offline
                                  maq_rohit
                                  wrote on last edited by
                                  #20

                                  hidden?

                                  1 Reply Last reply
                                  0
                                  • R riced

                                    SalarSoft wrote:

                                    There are keywords that are not documented.

                                    Tried reading the language specs? That documents them. I had a quick look at the StackOverflow link - if these are hidden features they can't have been looking at anything beyond C# in 5 :laugh: minutes.

                                    Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis The only valid measurement of code quality: WTFs/minute.

                                    K Offline
                                    K Offline
                                    Keith Barrow
                                    wrote on last edited by
                                    #21

                                    Actually,, undocumented keywords do exist in c#. They are undocumented as MS don't want us to use them (e.g. there is a high potential for a visit from the FU Fairy). See http://davesbox.com/archive/2008/12/29/documenting-undocumented-features.aspx[^]

                                    Sort of a cross between Lawrence of Arabia and Dilbert.[^]
                                    -Or-
                                    A Dead ringer for Kate Winslett[^]

                                    R 1 Reply Last reply
                                    0
                                    • K Keith Barrow

                                      Actually,, undocumented keywords do exist in c#. They are undocumented as MS don't want us to use them (e.g. there is a high potential for a visit from the FU Fairy). See http://davesbox.com/archive/2008/12/29/documenting-undocumented-features.aspx[^]

                                      Sort of a cross between Lawrence of Arabia and Dilbert.[^]
                                      -Or-
                                      A Dead ringer for Kate Winslett[^]

                                      R Offline
                                      R Offline
                                      riced
                                      wrote on last edited by
                                      #22

                                      Keith Barrow wrote:

                                      undocumented keywords

                                      That looks like an oxymoron - but that's a debate about semantics. There are identifiers, such as __reftype, that act as though they are keyword in .Net but are not specified as keywords in the C# language. These are implementation details so may not be 'keywords' in e.g. Mono. I don't know of a better way to describe such identifiers than 'undocumented keywords' but the phrase leaves me with bad taste - rather like beetroot. :)

                                      Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis The only valid measurement of code quality: WTFs/minute.

                                      1 Reply Last reply
                                      0
                                      • S SalarSoft

                                        Hidden Features of C# Personally I like ?? operator and started using it since then:

                                        private IList<Foo> _foo;

                                        public IList<Foo> ListOfFoo
                                        { get { return _foo ?? (_foo = new List<Foo>()); } }

                                        M Offline
                                        M Offline
                                        Monjurul Habib
                                        wrote on last edited by
                                        #23

                                        I think this is not hidden features .. most of C# developers already know this and this is available everywhere.

                                        L 1 Reply Last reply
                                        0
                                        • M Monjurul Habib

                                          I think this is not hidden features .. most of C# developers already know this and this is available everywhere.

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

                                          I do agree !

                                          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