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 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.
  • A AspDotNetDev

    What does it matter that it's a framework implementation and not implemented by the C# specification? Just as long as it accomplishes the same thing.

    Thou mewling ill-breeding pignut!

    S Offline
    S Offline
    Single Step Debugger
    wrote on last edited by
    #68

    The force is not as strong with the framework as it’s with the language itself. :-D

    There is only one Vera Farmiga and Salma Hayek is her prophet! Advertise here – minimum three posts per day are guaranteed.

    1 Reply Last reply
    0
    • A Alan Balkany

      The ability to look at a variable's memory location while in another part of the program. In C++, I sometimes use what I call the "Stakeout Debugging Pattern": I create a Watch expression on the address of a variable, so I can see how it changes while not in scope. (The debugger won't show variables not in scope). E.g. *(int *)0x12345678 But there's no way (that I know of) to do this in C#. This would help with debugging.

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

      Doesn't .NET constantly relocate variables to other memory locations? Which would mean you could watch an address, but if it changes that doesn't mean the variable you were watching is unreachable or out of scope. So what would you get out of it?

      It's an OO world.

      public class Naerling : Lazy<Person>{
      public void DoWork(){ throw new NotImplementedException(); }
      }

      A 1 Reply Last reply
      0
      • Sander RosselS Sander Rossel

        Doesn't .NET constantly relocate variables to other memory locations? Which would mean you could watch an address, but if it changes that doesn't mean the variable you were watching is unreachable or out of scope. So what would you get out of it?

        It's an OO world.

        public class Naerling : Lazy<Person>{
        public void DoWork(){ throw new NotImplementedException(); }
        }

        A Offline
        A Offline
        Alan Balkany
        wrote on last edited by
        #70

        You're right that garbage collection and relocation would invalidate the address, but this is only done when the application runs out of memory. Even better would be a way to watch a variable in another class, which would track these relocations. But that would require a more extensive change to the framework. Watching an address would be just about as useful, and is a more modest request.

        T 1 Reply Last reply
        0
        • M Member 9063556

          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 Offline
          P Offline
          Paul Michalik
          wrote on last edited by
          #71

          This is the most exotic opinion I have heard lately...[]

          M 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

            N Offline
            N Offline
            Naoya Yamaguchi
            wrote on last edited by
            #72

            They could improve C# in threading. C# is still a bit clumsy around threading. A thread is provided as a class in the system.threading namespace. And yet a lock is part of the C# language itself. I would like a syntax like:

            Future f = async double square(double x){return x * x;}

            A variable should be synchronizable with the "synchronized" keyword so that only one thread can access it at a time, like:

            synchronized double Balance;

            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
              Thornik
              wrote on last edited by
              #73

              I wanna have multi-return: (a, b) = SplitComplexNumber(d);

              J 1 Reply Last reply
              0
              • P PIEBALDconsult

                So?

                F Offline
                F Offline
                Florian Rappl
                wrote on last edited by
                #74

                What you mean "So"? goto is just goto - so that statement that it's different is wrong.

                P 1 Reply Last reply
                0
                • F Florian Rappl

                  What you mean "So"? goto is just goto - so that statement that it's different is wrong.

                  P Offline
                  P Offline
                  PIEBALDconsult
                  wrote on last edited by
                  #75

                  The concept is different.

                  F 1 Reply 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.

                    P Offline
                    P Offline
                    PIEBALDconsult
                    wrote on last edited by
                    #76

                    Yes, or what I frequently need:

                    assign default values ;

                    switch ( args.Length )
                    {
                    case 4 : parse parameter 4 ;
                    case 3 : parse parameter 3 ;
                    case 2 : parse parameter 2 ;
                    case 1 : parse parameter 1 ;
                    default : do something ;
                    }

                    1 Reply Last reply
                    0
                    • J Jasmine2501

                      THROWS, as an optional declaration. I would like the following... public void myfunction(int x) throws ArgumentException, OverflowException { } And, Java needs the other form of throws too, which I'd like to see in C# public void myfunction(int x) throws NONE { } ... for methods which can't throw exceptions.

                      P Offline
                      P Offline
                      PIEBALDconsult
                      wrote on last edited by
                      #77

                      But you can't know what may be thrown by something it calls, so I don't see the point.

                      J 1 Reply Last reply
                      0
                      • P PIEBALDconsult

                        The concept is different.

                        F Offline
                        F Offline
                        Florian Rappl
                        wrote on last edited by
                        #78

                        What kind of concept are you talking about? That the labels are also used from the switch statement? That's certainly true but has nothing to do with goto. But you have been talking about that goto SOME_LABEL is different than goto case WHATEVER - which is wrong. I think you have never seen any assembler output from C code or MSIL from C#, just look at my example which will give you an impression of the MSIL generated from a switch-case in C#.

                        P 1 Reply Last reply
                        0
                        • F Florian Rappl

                          What kind of concept are you talking about? That the labels are also used from the switch statement? That's certainly true but has nothing to do with goto. But you have been talking about that goto SOME_LABEL is different than goto case WHATEVER - which is wrong. I think you have never seen any assembler output from C code or MSIL from C#, just look at my example which will give you an impression of the MSIL generated from a switch-case in C#.

                          P Offline
                          P Offline
                          PIEBALDconsult
                          wrote on last edited by
                          #79

                          Florian Rappl wrote:

                          goto SOME_LABEL is different than goto case WHATEVER

                          Yes, of course.

                          Florian Rappl wrote:

                          assembler output

                          Has no bearing on the discussion.

                          F 1 Reply Last reply
                          0
                          • K Kent Sharkey

                            Yes! And gosub.

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

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

                            ahhh, the route to HELL :laugh:

                            1 Reply Last reply
                            0
                            • OriginalGriffO OriginalGriff

                              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.

                              E Offline
                              E Offline
                              Espen Harlinn
                              wrote on last edited by
                              #81

                              You're forgiven[^] ;)

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

                              OriginalGriffO 1 Reply Last reply
                              0
                              • E Espen Harlinn

                                You're forgiven[^] ;)

                                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
                                #82

                                That's all I need[^] to know.

                                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
                                • OriginalGriffO OriginalGriff

                                  That's all I need[^] to know.

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

                                  E Offline
                                  E Offline
                                  Espen Harlinn
                                  wrote on last edited by
                                  #83

                                  Good, I apologize[^] for the interruption ...

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

                                  OriginalGriffO 1 Reply Last reply
                                  0
                                  • E Espen Harlinn

                                    Good, I apologize[^] for the interruption ...

                                    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
                                    #84

                                    Why? What have you done?[^]

                                    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
                                    • 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

                                      R Offline
                                      R Offline
                                      rexnfx
                                      wrote on last edited by
                                      #85

                                      Co-routines or a better way to do single threaded faux-parallelism than perverting iterators.

                                      1 Reply Last reply
                                      0
                                      • P PIEBALDconsult

                                        Florian Rappl wrote:

                                        goto SOME_LABEL is different than goto case WHATEVER

                                        Yes, of course.

                                        Florian Rappl wrote:

                                        assembler output

                                        Has no bearing on the discussion.

                                        F Offline
                                        F Offline
                                        Florian Rappl
                                        wrote on last edited by
                                        #86

                                        Either you are incapable of understanding this or you just do not want to get this. Your statement that there are 2 gotos is wrong. From a language point of view using goto with some (arbitrary) label and with a case label is equivalent.

                                        P 1 Reply Last reply
                                        0
                                        • P PIEBALDconsult

                                          But you can't know what may be thrown by something it calls, so I don't see the point.

                                          J Offline
                                          J Offline
                                          Jasmine2501
                                          wrote on last edited by
                                          #87

                                          In Java, every function must declare all potential throws. The compiler looks down the call stack and makes sure that exceptions are either handled or declared in the throws. If not, it's a compilation error. That annoys many Java developers, which is why I think the feature should be optional. If it was optional, we could generate a warning on unhandled exceptions. IT would not be a compilation error like it is in Java. This wouldn't totally prevent any problems, but it would give developers a way to be more explicit about what exceptions can happen. For library designers this would be very helpful.

                                          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