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. What Language Features Do You Miss In C#?

What Language Features Do You Miss In C#?

Scheduled Pinned Locked Moved The Lounge
csharpjavascriptcomquestiondiscussion
102 Posts 36 Posters 1 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.
  • K Kent Sharkey

    Sure, it's on another discussion site[^], but that doesn't mean we can't also discuss it here. Personally, while it certainly doesn't fit in the "missing" category, I see them moving it closer and closer to a hybrid C#/JavaScript language with each new version.

    -------------- TTFN - Kent

    C Offline
    C Offline
    Chris C B
    wrote on last edited by
    #33

    On error resume next

    G K 2 Replies Last reply
    0
    • M Marc Clifton

      Multiple inheritance. Interfaces are useful as abstractions, but there are times I want to inherit concrete functionality from multiple classes. Marc

      Latest Article: C# and Ruby Classes: A Deep Dive
      My Blog

      J Offline
      J Offline
      JeremyBob
      wrote on last edited by
      #34

      +1 from me

      1 Reply Last reply
      0
      • K Kent Sharkey

        Sure, it's on another discussion site[^], but that doesn't mean we can't also discuss it here. Personally, while it certainly doesn't fit in the "missing" category, I see them moving it closer and closer to a hybrid C#/JavaScript language with each new version.

        -------------- TTFN - Kent

        M Offline
        M Offline
        m0sa
        wrote on last edited by
        #35

        - aspect oriented programming (PostSharp...) - mixin support - serializable expressions

        1 Reply Last reply
        0
        • M Marc A Brown

          I would like to see the addition of a keyword to allow fallthrough in a switch statement (maybe "nobreak"?). I don't need/want to do that often, so the compiler preventing "accidental" fallthrough is nice; however, it sure would be nice to be able to fall through when necessary.

          M Offline
          M Offline
          Marach
          wrote on last edited by
          #36

          you can type several 'case' statements one after the other. contrived example:

          int number = GetNumberBetween1And5();
          string text = null;
          switch( number ) {
          case 1:
          text = "1";
          break;
          case 2:
          case 3:
          case 4:
          text = "2 or 3 or 4";
          break;
          case 5:
          text = "5";
          break;
          }

          is that type of fall-through what you said you're missing?

          M 1 Reply Last reply
          0
          • P PIEBALDconsult

            A goto case is not a goto. But, yes, I don't like break in a switch; in my opinion break should only be for loops only.

            OriginalGriffO Offline
            OriginalGriffO Offline
            OriginalGriff
            wrote on last edited by
            #37

            I agree - it isn't. But...it is a out-of-structure code flow indicator, which can easily create the same spaghetti code as a goto. So on balance, while I found the no-drop-through rule limiting at first, I don't miss it so much now. I just restructure the code to not need it in the same way that I don't need goto itself. And I definitely agree on break - the switch version should have used a different word: "esac" or "join" perhaps.

            If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.

            "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
            "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

            1 Reply Last reply
            0
            • E Espen Harlinn

              You certainly go straight to The Heart of Everything[^]

              Espen Harlinn Principal Architect, Software - Goodtech Projects & Services AS Projects promoting programming in "natural language" are intrinsically doomed to fail. Edsger W.Dijkstra

              OriginalGriffO Offline
              OriginalGriffO Offline
              OriginalGriff
              wrote on last edited by
              #38

              Because I have A Dangerous Mind[^] :-D

              If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.

              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
              "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

              E 1 Reply Last reply
              0
              • B Bassam Abdul Baki

                Having a #thread block similar to the #region one except it makes that part of the code threaded and only within a single function. :)

                Web - BM - RSS - Math - LinkedIn

                S Offline
                S Offline
                Sentenryu
                wrote on last edited by
                #39

                like this[^]?

                I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p) "Given the chance I'd rather work smart than work hard." - PHS241

                B 1 Reply Last reply
                0
                • P Paulo Zemek

                  In my case, actually, for every Foo<T> I also have an IFoo where the parameters are as object instead of T. I think java have such feature (I know, in java the implementation is completely different)... I think they use: Foo<?> to say that they don't know the type being used. It is slower than having it rightly typed, but it is faster than having it as dynamic or through reflection.

                  S Offline
                  S Offline
                  Sentenryu
                  wrote on last edited by
                  #40

                  why the heck you just don't use a generic method?

                  public void DoGenericStuff(Foo foo)
                  {
                  ....
                  }

                  I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p) "Given the chance I'd rather work smart than work hard." - PHS241

                  P 1 Reply Last reply
                  0
                  • P PIEBALDconsult

                    Method-scoped variables like in VB (static). Defining Extension Methods by applying the Attribute like in VB (rather than this). A proper assignment operator like in Pascal := :-D A proper define directive like in C/C++ # define Pi 3.14 Support for enum in where clauses for generic types -- class C<T> where T : enum ... No default modifiers (public, private, virtual, sealed, etc.). Multiple Inheritence would be good too.

                    S Offline
                    S Offline
                    Sentenryu
                    wrote on last edited by
                    #41

                    PIEBALDconsult wrote:

                    A proper assignment operator like in Pascal :=:-D
                     
                    A proper define directive like in C/C++ # define Pi 3.14 ... Multiple Inheritence would be good too.

                    if any of thouse got added i would be sooo mad, i alread have too much bad code to deal even without those...

                    I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p) "Given the chance I'd rather work smart than work hard." - PHS241

                    1 Reply Last reply
                    0
                    • H H Brydon

                      What I would like to see in the language: - Destructors that destruct (not the silly Dispose() stuff) [you can easily trigger local garbage collection with an exit from scope] - Ability to use arrays with non-zero origin - inline operator||(), inline operator&&() which implement short circuit logic

                      -- Harvey

                      S Offline
                      S Offline
                      Sentenryu
                      wrote on last edited by
                      #42

                      H.Brydon wrote:

                      Destructors that destruct (not the silly Dispose() stuff) [you can easily trigger local garbage collection with an exit from scope]

                      I couldn't agree more.

                      I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p) "Given the chance I'd rather work smart than work hard." - PHS241

                      1 Reply Last reply
                      0
                      • B Brady Kelly

                        I want lambda expressions, that can be evaluated at compile time, allowed in attributes, to avoid nasty string literals.

                        S Offline
                        S Offline
                        Sentenryu
                        wrote on last edited by
                        #43

                        that's not allowed with an Expression parameter?

                        I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p) "Given the chance I'd rather work smart than work hard." - PHS241

                        1 Reply Last reply
                        0
                        • T thrakazog

                          My answer is always multiple inheritance. Times that I would use it are rare. But when those times come up man do I ever want that.

                          Play my game Gravity: IOS[^], Android[^], Windows Phone 7[^]

                          M Offline
                          M Offline
                          Member 9063556
                          wrote on last edited by
                          #44

                          Plugin support is always an issue with C#. You can't use User Controls inside a Console Application, which makes that coding needs to be done each class. C++ holds great support for adding plugins for extra code (.h files sepcifically are useful) but in the end, you can't blame Microsoft for their .NET approach to everything, The time of a CLI is dead (Except PowerShell, IMO)

                          P 1 Reply Last reply
                          0
                          • S Sentenryu

                            like this[^]?

                            I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p) "Given the chance I'd rather work smart than work hard." - PHS241

                            B Offline
                            B Offline
                            Bassam Abdul Baki
                            wrote on last edited by
                            #45

                            Nice! Although one difference in my envisioned approach would be that I could potentially have sequential or embded #thread blocks within the same function. With this, you have to make each thread a function as opposed to using it in a for or while loop, for example.

                            Web - BM - RSS - Math - LinkedIn

                            1 Reply Last reply
                            0
                            • M Marach

                              you can type several 'case' statements one after the other. contrived example:

                              int number = GetNumberBetween1And5();
                              string text = null;
                              switch( number ) {
                              case 1:
                              text = "1";
                              break;
                              case 2:
                              case 3:
                              case 4:
                              text = "2 or 3 or 4";
                              break;
                              case 5:
                              text = "5";
                              break;
                              }

                              is that type of fall-through what you said you're missing?

                              M Offline
                              M Offline
                              Marc A Brown
                              wrote on last edited by
                              #46

                              I already knew about (and use) that type of fallthrough (but thanks for pointing it out anyway). I'm talking about a case (no pun intended) where you have an action to perform in two cases that requires some kind of setup in one of the cases but not the other.

                              switch(whichAction)
                              {
                              case Actions.ActionWithSetup:
                              DoSetup();
                              case Actions.Action:
                              DoAction();
                              break;
                              }

                              In this example, in the one case, DoSetup is performed, followed by DoAction; in the other case only DoAction is performed. You can do this in C (and Java as I recall) but not in C#. I'm fine with the language not allowing the fallthrough to happen unintentionally but think there should be a keyword to allow it. For example:

                              switch(whichAction)
                              {
                              case Actions.ActionWithSetup:
                              DoSetup();
                              nobreak;
                              case Actions.Action:
                              DoAction();
                              break;
                              }

                              I realize that in my example I could simply call DoAction in both cases (and that's what I would do, given the C# limitation); and I also understand that if I've got a block of code in the second case, I can break it out into a separate method and call that method in both cases (which again is what I would do); however, if it's a really small block of code, I don't necessarily want to create a new method for it or duplicate the code.

                              M P 2 Replies Last reply
                              0
                              • M Marc A Brown

                                I already knew about (and use) that type of fallthrough (but thanks for pointing it out anyway). I'm talking about a case (no pun intended) where you have an action to perform in two cases that requires some kind of setup in one of the cases but not the other.

                                switch(whichAction)
                                {
                                case Actions.ActionWithSetup:
                                DoSetup();
                                case Actions.Action:
                                DoAction();
                                break;
                                }

                                In this example, in the one case, DoSetup is performed, followed by DoAction; in the other case only DoAction is performed. You can do this in C (and Java as I recall) but not in C#. I'm fine with the language not allowing the fallthrough to happen unintentionally but think there should be a keyword to allow it. For example:

                                switch(whichAction)
                                {
                                case Actions.ActionWithSetup:
                                DoSetup();
                                nobreak;
                                case Actions.Action:
                                DoAction();
                                break;
                                }

                                I realize that in my example I could simply call DoAction in both cases (and that's what I would do, given the C# limitation); and I also understand that if I've got a block of code in the second case, I can break it out into a separate method and call that method in both cases (which again is what I would do); however, if it's a really small block of code, I don't necessarily want to create a new method for it or duplicate the code.

                                M Offline
                                M Offline
                                Marach
                                wrote on last edited by
                                #47

                                Thanks for elaborating, I understand now. And I agree that C# language should have some construct like the suggested one to allow the fall-through.

                                1 Reply Last reply
                                0
                                • A AspDotNetDev

                                  Inline assembler.

                                  Thou mewling ill-breeding pignut!

                                  T Offline
                                  T Offline
                                  Tim Schwallie
                                  wrote on last edited by
                                  #48

                                  I believe that's been there since version 1.0

                                  A 1 Reply Last reply
                                  0
                                  • S Steve Wellens

                                    sprintf sscanf

                                    Steve Wellens

                                    G Offline
                                    G Offline
                                    glennPattonWork3
                                    wrote on last edited by
                                    #49

                                    Amen, would make life easier at the moment! mind you can get them from C++ Glenn

                                    1 Reply Last reply
                                    0
                                    • C Chris C B

                                      On error resume next

                                      G Offline
                                      G Offline
                                      glennPattonWork3
                                      wrote on last edited by
                                      #50

                                      VB error handling, really?

                                      1 Reply Last reply
                                      0
                                      • K Kent Sharkey

                                        Sure, it's on another discussion site[^], but that doesn't mean we can't also discuss it here. Personally, while it certainly doesn't fit in the "missing" category, I see them moving it closer and closer to a hybrid C#/JavaScript language with each new version.

                                        -------------- TTFN - Kent

                                        T Offline
                                        T Offline
                                        Tim Schwallie
                                        wrote on last edited by
                                        #51

                                        Enum that supports other types, not just integral types. A required tag on the end of block regions. Why? Cause it can become a bitch knowing which '}' belongs with what after a while and folks are too lazy to comment. Or VS could get better and put a comment there for you. But then this isn't about VS. Improved Friend relationships between DLL's. Current way of setting up Friend relationships is awkward.

                                        1 Reply Last reply
                                        0
                                        • S Sentenryu

                                          why the heck you just don't use a generic method?

                                          public void DoGenericStuff(Foo foo)
                                          {
                                          ....
                                          }

                                          I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p) "Given the chance I'd rather work smart than work hard." - PHS241

                                          P Offline
                                          P Offline
                                          Paulo Zemek
                                          wrote on last edited by
                                          #52

                                          Hahahahaha. You didn't get it at all. Imagine that for some reason you don't know the T type at compile-time. You are in an event or something and you are receiving a valid value, but it is cast as object. How do you do a call to the generic class without knowing its generic type? In such case, it is up to you to do the cast, but you don't have the destination type at compile time. The solution in such situation is to use reflection or dynamic. I solve the problem having an untyped interface. That works very well for my classes, but not to already existing classes. Even if it is not a generic class situation, you can see that happening with database connections. You have SqlConnection, OracleConnection, SqlCommand, OracleCommand, SqlParameter, OracleParameter and so on. But you can use all of them al IDbConnection, IDbCommand and so on. So, you create a parameter using the command... you dont know if it is an OracleParameter or SqlParameter... but it is not important, as when you add a parameter to a command the driver do the cast for you. (Ok, it is a little stupid that you create the parameter and it is not added automatically... but I want to ilustrate a situation where you have a valid value [the parameter] but you don't have the valid type).

                                          S 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