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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. The Lounge
  3. No typedef in C# 2.0

No typedef in C# 2.0

Scheduled Pinned Locked Moved The Lounge
csharpquestion
28 Posts 13 Posters 10 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.
  • M Matt Gerrans

    Look more closely. Matt Gerrans

    L Offline
    L Offline
    Long Gone
    wrote on last edited by
    #17

    Matt Newman wrote: I thought the # was just a cool way of drawing two +'s # => ++ so ## => ++++ Matt Gerrans wrote: Look more closely. Obviously I am missing something. P.S. – for all you anal retentive folks out there tempted to comment on my spelling or grammar save your energy. I don’t care. Don't shoot! I'm only the piano player messenger. Beatress

    M 1 Reply Last reply
    0
    • R Rei Miyasaka

      Remember in the Windows API how when you hunt through the jumble of typedefs and #defines, ints and HANDLEs and DWORDs and FAR and a bunch of other stuff turn to be the same thing? Or how MessageBox() and MessageBoxA() and _MessageBox() and __MessageBox() were all the same thing? I think the goal is to discourage that sort of thing. It'd be easy to use but it'd also be easier to abuse. Integrity is a key design objective in .NET.

      V Offline
      V Offline
      Vagif Abilov
      wrote on last edited by
      #18

      Agree. How many various 32-bit types will we find in Win SDK headers. I guess several hundred. Вагиф Абилов MCP (Visual C++) Oslo, Norway If you're in a war, instead of throwing a hand grenade at the enemy, throw one of those small pumpkins. Maybe it'll make everyone think how stupid war is, and while they are thinking, you can throw a real grenade at them. Jack Handey.

      J 1 Reply Last reply
      0
      • L Long Gone

        Matt Newman wrote: I thought the # was just a cool way of drawing two +'s # => ++ so ## => ++++ Matt Gerrans wrote: Look more closely. Obviously I am missing something. P.S. – for all you anal retentive folks out there tempted to comment on my spelling or grammar save your energy. I don’t care. Don't shoot! I'm only the piano player messenger. Beatress

        M Offline
        M Offline
        Matt Gerrans
        wrote on last edited by
        #19

        Obviously:

        # == ++ == ++++
        ++

        QED ;P Matt Gerrans

        R L 2 Replies Last reply
        0
        • M Matt Gerrans

          Obviously:

          # == ++ == ++++
          ++

          QED ;P Matt Gerrans

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

          Or you can take 2 +s, extend the lines and arrange them diagonally:

          | | | |
          -+--- | -+--+-
          | + | = | |
          | ---+- -+--+-
          | | | |

          M 1 Reply Last reply
          0
          • R Rei Miyasaka

            Or you can take 2 +s, extend the lines and arrange them diagonally:

            | | | |
            -+--- | -+--+-
            | + | = | |
            | ---+- -+--+-
            | | | |

            M Offline
            M Offline
            Matt Gerrans
            wrote on last edited by
            #21

            Two distorted +'s perhaps. Matt Gerrans

            R 1 Reply Last reply
            0
            • M Matt Gerrans

              Two distorted +'s perhaps. Matt Gerrans

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

              :)

              1 Reply Last reply
              0
              • A Alvaro Mendez

                I've been doing some work with generics in C# 2.0 and I have to say that I'm a bit dissapointed by the fact that typedef has been omitted from the language. I would like to do the equivalent of:

                namespace MyNamespace
                {
                public typedef MyGenericClass<Class1, Class2, Class3, ...> MySimplerName;
                }

                I know about the using statement, but it only works on the current file. I would have to repeat it in every file! The only workaround is to derive the new class. However, since the constructors are not inherited, I would have to redefine them:

                namespace MyNamespace
                {
                public MySimplerName : MyGenericClass<Class1, Class2, Class3, ...>
                {
                public MySimplerName(Class1 c1) :
                base(c1)
                {
                }

                  public MySimplerName(Class1 c1, Class2 c2) : 
                     base(c1, c2) 
                  { 
                  }
                

                }
                }

                Seems like a hassle to me, which the typedef would have made unnecessary. Anyone have any insight as to why it was left out? Regards, Alvaro


                Victory means exit strategy, and it's important for the President to explain to us what the exit strategy is. -- GWB, 1999.

                G Offline
                G Offline
                Giles
                wrote on last edited by
                #23

                I could see how that would be very useful, and help clean up code readability. Something I take for granted in C++, and don't think about. Personally, I would quite like a preprocessor as well.

                1 Reply Last reply
                0
                • R Rei Miyasaka

                  Remember in the Windows API how when you hunt through the jumble of typedefs and #defines, ints and HANDLEs and DWORDs and FAR and a bunch of other stuff turn to be the same thing? Or how MessageBox() and MessageBoxA() and _MessageBox() and __MessageBox() were all the same thing? I think the goal is to discourage that sort of thing. It'd be easy to use but it'd also be easier to abuse. Integrity is a key design objective in .NET.

                  E Offline
                  E Offline
                  Emilio Garavaglia
                  wrote on last edited by
                  #24

                  "Interity" or "Integralism"? What's the matter with a type name redefinition for my own use, if it is closed in my own namespace? The (ab)use of type redefinition in Win32 derived from the fact that it was designed in flat namespace environment (plain C). All the consideration about templates and generics are correct, but the idea to alias a frequently used name dosn't semm to me so peregrine. My opinion is that ... they simply forgot it. And we are trying to justify them by "inventing" forcing anyone to use "patterns" also when not the case. And calling this "intrgrity". Did The "goto" history, blamed by zealots and rewed recently, teach anything ?? 2 bugs found. > recompile ... 65534 bugs found. :doh:

                  1 Reply Last reply
                  0
                  • M Matt Gerrans

                    Obviously:

                    # == ++ == ++++
                    ++

                    QED ;P Matt Gerrans

                    L Offline
                    L Offline
                    Long Gone
                    wrote on last edited by
                    #25

                    Good one!:) P.S. – for all you anal retentive folks out there tempted to comment on my spelling or grammar save your energy. I don’t care. Don't shoot! I'm only the piano player messenger. Beatress

                    1 Reply Last reply
                    0
                    • V Vagif Abilov

                      Agree. How many various 32-bit types will we find in Win SDK headers. I guess several hundred. Вагиф Абилов MCP (Visual C++) Oslo, Norway If you're in a war, instead of throwing a hand grenade at the enemy, throw one of those small pumpkins. Maybe it'll make everyone think how stupid war is, and while they are thinking, you can throw a real grenade at them. Jack Handey.

                      J Offline
                      J Offline
                      Jorgen Sigvardsson
                      wrote on last edited by
                      #26

                      The thing is though that we ain't supposed to know that they're 32 bits wide.. ;P Good music: In my rosary[^]

                      1 Reply Last reply
                      0
                      • A Alvaro Mendez

                        I've been doing some work with generics in C# 2.0 and I have to say that I'm a bit dissapointed by the fact that typedef has been omitted from the language. I would like to do the equivalent of:

                        namespace MyNamespace
                        {
                        public typedef MyGenericClass<Class1, Class2, Class3, ...> MySimplerName;
                        }

                        I know about the using statement, but it only works on the current file. I would have to repeat it in every file! The only workaround is to derive the new class. However, since the constructors are not inherited, I would have to redefine them:

                        namespace MyNamespace
                        {
                        public MySimplerName : MyGenericClass<Class1, Class2, Class3, ...>
                        {
                        public MySimplerName(Class1 c1) :
                        base(c1)
                        {
                        }

                          public MySimplerName(Class1 c1, Class2 c2) : 
                             base(c1, c2) 
                          { 
                          }
                        

                        }
                        }

                        Seems like a hassle to me, which the typedef would have made unnecessary. Anyone have any insight as to why it was left out? Regards, Alvaro


                        Victory means exit strategy, and it's important for the President to explain to us what the exit strategy is. -- GWB, 1999.

                        D Offline
                        D Offline
                        Daniel Grunwald
                        wrote on last edited by
                        #27

                        It's called using, not typedef: using StringPair = System.Collections.Generic.KeyValuePair<string, string>;

                        A 1 Reply Last reply
                        0
                        • D Daniel Grunwald

                          It's called using, not typedef: using StringPair = System.Collections.Generic.KeyValuePair<string, string>;

                          A Offline
                          A Offline
                          Alvaro Mendez
                          wrote on last edited by
                          #28

                          I know about using, but it's only available for the current file. It would need to be repeated in every file you'd want to use StringPair. using is just an alias; it doesn't define a distinct type like typedef does (in C++). Regards, Alvaro


                          Victory means exit strategy, and it's important for the President to explain to us what the exit strategy is. -- GWB, 1999.

                          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