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. C# 4.0

C# 4.0

Scheduled Pinned Locked Moved The Lounge
csharpquestiondiscussionannouncement
233 Posts 75 Posters 1.1k 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 MrPlankton

    You of course would write it, to handle that case.

    MrPlankton

    P Offline
    P Offline
    Pawel Krakowiak
    wrote on last edited by
    #100

    MrPlankton wrote:

    You of course would write it, to handle that case.

    I thought so. :) Then it's the same as with the current lack of optional method arguments - you have to write overloads and people complain. Now you would have to write void methods...

    M 1 Reply Last reply
    0
    • J Jamie Nordmeyer

      So now that C# 4.0 is being talked about, I was wondering what people thought would be good additions to the language. Sorry if this is a repost, but I went through several pages, and didn't see anything, so... What I'd frankly love to see would be tuples. Rather than having to use multiple 'out' parameters, you'd just return multiple values:

      public int,int MinMax(int[] numbers)
      {
      int min, max;
      // Code to calculate min/max

      return min, max;
      }

      What do you think? What would be good for the next version?

      Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan Portland, Oregon, USA

      H Offline
      H Offline
      Hooga Booga
      wrote on last edited by
      #101

      Free beer!

      P 1 Reply Last reply
      0
      • J Jamie Nordmeyer

        So now that C# 4.0 is being talked about, I was wondering what people thought would be good additions to the language. Sorry if this is a repost, but I went through several pages, and didn't see anything, so... What I'd frankly love to see would be tuples. Rather than having to use multiple 'out' parameters, you'd just return multiple values:

        public int,int MinMax(int[] numbers)
        {
        int min, max;
        // Code to calculate min/max

        return min, max;
        }

        What do you think? What would be good for the next version?

        Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan Portland, Oregon, USA

        U Offline
        U Offline
        User 3728064
        wrote on last edited by
        #102

        really interesting!

        1 Reply Last reply
        0
        • J Jamie Nordmeyer

          here here!

          Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan Portland, Oregon, USA

          G Offline
          G Offline
          Giampaolo Papotti
          wrote on last edited by
          #103

          I strongly Agree! C# cut-offs from c++ were really too deep. cons keyword (both on parameters and members signatures) shoud be a MUST in any oo language. And what about the annoying lack of default in parameters? I'd like to see c# designers and gurus dealing with Office PIA... I'm sure they would have a private build of csc.exe with default parameters implementeed .... InvokeExcelStuff(theOnlyNeededParameter, null, null, null, null, null, null, null, null, null, null, null, null, null, null....)

          S 1 Reply Last reply
          0
          • J Jamie Nordmeyer

            So now that C# 4.0 is being talked about, I was wondering what people thought would be good additions to the language. Sorry if this is a repost, but I went through several pages, and didn't see anything, so... What I'd frankly love to see would be tuples. Rather than having to use multiple 'out' parameters, you'd just return multiple values:

            public int,int MinMax(int[] numbers)
            {
            int min, max;
            // Code to calculate min/max

            return min, max;
            }

            What do you think? What would be good for the next version?

            Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan Portland, Oregon, USA

            P Offline
            P Offline
            pherschel
            wrote on last edited by
            #104

            I'd like to see built in threading. Example: int x = CalcXDataValues() &; <- run as thread int y = CalcYDataValues() &; int z = x + y; // will not execute until x and y are set!

            - Pete

            1 Reply Last reply
            0
            • J Jamie Nordmeyer

              So now that C# 4.0 is being talked about, I was wondering what people thought would be good additions to the language. Sorry if this is a repost, but I went through several pages, and didn't see anything, so... What I'd frankly love to see would be tuples. Rather than having to use multiple 'out' parameters, you'd just return multiple values:

              public int,int MinMax(int[] numbers)
              {
              int min, max;
              // Code to calculate min/max

              return min, max;
              }

              What do you think? What would be good for the next version?

              Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan Portland, Oregon, USA

              A Offline
              A Offline
              Anubisasc
              wrote on last edited by
              #105

              I would like to be able to do something like this:

              const string[] constantArray = {
              "String1",
              "String2",
              "String3"
              };

              Right now you can only create a static read only array.

              1 Reply Last reply
              0
              • P Pawel Krakowiak

                MrPlankton wrote:

                You of course would write it, to handle that case.

                I thought so. :) Then it's the same as with the current lack of optional method arguments - you have to write overloads and people complain. Now you would have to write void methods...

                M Offline
                M Offline
                MrPlankton
                wrote on last edited by
                #106

                Well you could cast it to the method you want even if there is no left side argument. (int)functA("stuff"); I'm just saying having the return type as part of the signiture would be nice to have from time to time.

                MrPlankton

                P 1 Reply Last reply
                0
                • C Christian Graus

                  I'd love to see a const keyword on parameters to methods, and optional parameters. Both of which seem simple enough.

                  Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.

                  G Offline
                  G Offline
                  grgran
                  wrote on last edited by
                  #107

                  What would you expect 'const' to do? Would it just be the programmers promise not to change the contents of the object (generating an error if an assignment was attempted)? Would it also be able to determine if a method call on the object changed the state of the object and generate an error? If const is accepted as a parameter keyword should it also be accepted as a method modifier? How would optional parameters differ from the current params keyword?

                  1 Reply Last reply
                  0
                  • M MrPlankton

                    Well you could cast it to the method you want even if there is no left side argument. (int)functA("stuff"); I'm just saying having the return type as part of the signiture would be nice to have from time to time.

                    MrPlankton

                    P Offline
                    P Offline
                    Pawel Krakowiak
                    wrote on last edited by
                    #108

                    MrPlankton wrote:

                    I'm just saying having the return type as part of the signiture would be nice to have from time to time

                    I know, I've been there myself. ;)

                    1 Reply Last reply
                    0
                    • J Jamie Nordmeyer

                      Here's an example of what I think he's saying:

                      public void DoSomething(const Employee emp)
                      {
                      emp.Age = 32; // This would not compile.
                      }

                      An object is passed by reference, so its properties are settable. You don't want to make the Age property read only, because normally, you want the consumer to be able to set it. But what if DoSomething was meant to be a final validation, and you didn't want anything in the object to change, because it could mess up state elsewhere? The const keyword would allow the developer to leave a property or field writable, but still be able to restrict when it could be written to.

                      Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan Portland, Oregon, USA

                      D Offline
                      D Offline
                      Donkey Master
                      wrote on last edited by
                      #109

                      Ok, I think I get it. So, I would be able to call methods and get properties and fields, but forbidden from setting fields and properties. Well, there are still the methods to change the data, so I guess that optimization-wise, this doesn't help. So, it's mostly syntactic sugar, a contract constraint. I'd put it in the same category as varargs, in terms of usefulness. You say that VB.NET has this feature today? How does it work when you import a VB.NET library to another language, like C#?

                      "Computer Science is no more about computers than astronomy is about telescopes." - Edsger Dijkstra

                      1 Reply Last reply
                      0
                      • J Jamie Nordmeyer

                        So now that C# 4.0 is being talked about, I was wondering what people thought would be good additions to the language. Sorry if this is a repost, but I went through several pages, and didn't see anything, so... What I'd frankly love to see would be tuples. Rather than having to use multiple 'out' parameters, you'd just return multiple values:

                        public int,int MinMax(int[] numbers)
                        {
                        int min, max;
                        // Code to calculate min/max

                        return min, max;
                        }

                        What do you think? What would be good for the next version?

                        Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan Portland, Oregon, USA

                        G Offline
                        G Offline
                        grgran
                        wrote on last edited by
                        #110

                        I'd like to see operator overloading supported in Interfaces, but this obvious has problems for languages that don't support op overloading. Here's what I'm thinking interface INumeric { ... overloads for +, -, /, *, remainder, (others) } class stats<T> where T:INumeric { ... methods to calculate staticial values on type T } This doesn't have to be done with interfaces (that just seems easiest). If all the numerics shared a common base class that would also be ok. I realize that this can be done with out op overloading (using only method calls), but I'd like to see it build-in so the standard types implement a basic set of operators, and users could implement their own (possibly) wacky types. That way the possibly complex methods used to calculate need only be written once. Consider, calculating Navier–Stokes equations over a large region, then as you drill down into a small region you find that you need more precision than the ~15 of doubles, so you write a high precision class that is much slower but provide the precision required. If there were a natural way to create such a class then it could just be plugged in via generics rather than requiring a bunch of complex equations to be rewritten for the new type or for method (rather than operator) expansion. Ok, that's enough wackiness for one day

                        1 Reply Last reply
                        0
                        • J Jamie Nordmeyer

                          So now that C# 4.0 is being talked about, I was wondering what people thought would be good additions to the language. Sorry if this is a repost, but I went through several pages, and didn't see anything, so... What I'd frankly love to see would be tuples. Rather than having to use multiple 'out' parameters, you'd just return multiple values:

                          public int,int MinMax(int[] numbers)
                          {
                          int min, max;
                          // Code to calculate min/max

                          return min, max;
                          }

                          What do you think? What would be good for the next version?

                          Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan Portland, Oregon, USA

                          G Offline
                          G Offline
                          Gonzalo Brusella
                          wrote on last edited by
                          #111

                          Default initialization on auto-implemented properties!!

                          I'm on a Fuzzy State: Between 0 an 1

                          1 Reply Last reply
                          0
                          • P Pawel Krakowiak

                            Sunny Ahuwanya wrote:

                            I think they already degraded the language in C# 3 by adding extension methods

                            I think of them as of an improvement and use them. :)

                            S Offline
                            S Offline
                            Sunny Ahuwanya
                            wrote on last edited by
                            #112

                            Pawel Krakowiak wrote:

                            I think of them as of an improvement and use them. Smile

                            Can anyone explain to me how extension methods are an improvement? Besides helping to sell LINQ and encouraging programmers to write code in a non-portable, non object oriented manner, what is the point of extension methods?

                            Sunny Ahuwanya "The beauty of the desert is that it hides a well somewhere" -- Antoine de Saint Exupéry

                            S P J 3 Replies Last reply
                            0
                            • J Jamie Nordmeyer

                              So now that C# 4.0 is being talked about, I was wondering what people thought would be good additions to the language. Sorry if this is a repost, but I went through several pages, and didn't see anything, so... What I'd frankly love to see would be tuples. Rather than having to use multiple 'out' parameters, you'd just return multiple values:

                              public int,int MinMax(int[] numbers)
                              {
                              int min, max;
                              // Code to calculate min/max

                              return min, max;
                              }

                              What do you think? What would be good for the next version?

                              Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan Portland, Oregon, USA

                              K Offline
                              K Offline
                              Kenneth Kasajian
                              wrote on last edited by
                              #113

                              I have 5 that I want Basic stuff: 1. I'd like compile-time calculation and compile-time execution support. I'd like to have a compile-time assert, as well as simple calculations. I don't want to do calculations at runtime on static data I have a compile time. 2. I'd like to see language support for mixins. 3. I'd like to be able to write "const-correct" code the way I can in C++. I'd like to be able to mark a method read-only so that I know it doesn't modify the data. I'd like to be able to have a read-only object and pass it to other functions knowing that they cannot modify it. This really helps when reading other people's code, too, 'cause you can easily determine their intent. The following I think are features that the language will eventually have -- mark my words. 1. Language support for mocking. For instance, I should be able to instantiate an interface and get some dummy default implementation. This will help with stubbing. And I should be able to configure the mock in a simple way to do some other "basic" functions. 2. Language support for unit testing. I realize that everyone's thinking why, 'cause NUnit works, etc. But if you allow your mind to wonder why it would be like to have language support for Unit Testing, you can imagine some interesting possiblities. For instance, how about methods won't compile unless they have tests. Or if every path doesn't isn't executed, then you get a compiler warning. Maybe those aren't the best examples, but smarter people can come up with something more interesting.

                              ken@kasajian.com / www.kasajian.com

                              1 Reply Last reply
                              0
                              • P PIEBALDconsult

                                Oh, well then... Treat the using directive as an error. While you're at it, require full attribute names.

                                S Offline
                                S Offline
                                Sunny Ahuwanya
                                wrote on last edited by
                                #114

                                There are so many things wrong with extension methods that I *still* get baffled how the geniuses at M$ included that as a feature. I guess LINQ must have been a HUGE thing for every team to bend their libraries and languages to 'force' it to fit in. I just want the option not to use it or make me use it in the "good way". This is just like the way you could set option strict in classic VB. Luckily almost all Microsoft extension methods come with in their exclusive namespaces. So all I have to do now is not include those namespaces BUT that doesn't prevent some other genius at XYZ company to pack extension methods with regular methods in their libraries and forcing ME to write bad code. Chip on my shoulder :)

                                Sunny Ahuwanya "The beauty of the desert is that it hides a well somewhere" -- Antoine de Saint Exupéry

                                S P S 3 Replies Last reply
                                0
                                • V Vikram A Punathambekar

                                  S. Senthil Kumar wrote:

                                  The methods themselves would have to be declared const, just like in C++.

                                  Yeah, I wrote that myself, without reading your post. :doh:

                                  S. Senthil Kumar wrote:

                                  if a method declared const in v1 of the library became non const in v2, the "constness" guarantee will get broken (unless there is a runtime check).

                                  I'm not sure I understand, could you please explain?

                                  Cheers, Vıkram.


                                  "You idiot British surprise me that your generators which grew up after Mid 50s had no brain at all." - Adnan Siddiqi.

                                  S Offline
                                  S Offline
                                  S Senthil Kumar
                                  wrote on last edited by
                                  #115

                                  Let's say you are using a library with the following code

                                  // Assembly SomeLib.dll

                                  class C
                                  {
                                  void someMethod() const {...}
                                  }

                                  and the code using it looks like this

                                  // Assembly App.exe

                                  void usingMethod(const C obj)
                                  {
                                  obj.someMethod(); // ok, because someMethod is const
                                  }

                                  Now let's say a new version of SomeLib.dll comes out and in that version, someMethod() becomes non-const. With C++, App.exe would require recompiling with the modified header file, and the compiler would be able to flag the error in usingMethod (non const method call on a const object). With .NET and binary compatibility, there's no recompiling necessary - you just drop in the new DLL and now the const guarantee is broken. It would be a silent breaking change, unless there is a runtime check.

                                  Regards Senthil [MVP - Visual C#] _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro

                                  V 1 Reply Last reply
                                  0
                                  • S Sunny Ahuwanya

                                    There are so many things wrong with extension methods that I *still* get baffled how the geniuses at M$ included that as a feature. I guess LINQ must have been a HUGE thing for every team to bend their libraries and languages to 'force' it to fit in. I just want the option not to use it or make me use it in the "good way". This is just like the way you could set option strict in classic VB. Luckily almost all Microsoft extension methods come with in their exclusive namespaces. So all I have to do now is not include those namespaces BUT that doesn't prevent some other genius at XYZ company to pack extension methods with regular methods in their libraries and forcing ME to write bad code. Chip on my shoulder :)

                                    Sunny Ahuwanya "The beauty of the desert is that it hides a well somewhere" -- Antoine de Saint Exupéry

                                    S Offline
                                    S Offline
                                    S Senthil Kumar
                                    wrote on last edited by
                                    #116

                                    Sunny Ahuwanya wrote:

                                    There are so many things wrong with extension methods

                                    Care to list some of them? I get that they can pollute the list of methods in a class and can cause calls to unintended methods, what else do you find wrong?

                                    Regards Senthil [MVP - Visual C#] _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro

                                    S P 2 Replies Last reply
                                    0
                                    • S Sunny Ahuwanya

                                      Pawel Krakowiak wrote:

                                      I think of them as of an improvement and use them. Smile

                                      Can anyone explain to me how extension methods are an improvement? Besides helping to sell LINQ and encouraging programmers to write code in a non-portable, non object oriented manner, what is the point of extension methods?

                                      Sunny Ahuwanya "The beauty of the desert is that it hides a well somewhere" -- Antoine de Saint Exupéry

                                      S Offline
                                      S Offline
                                      S Senthil Kumar
                                      wrote on last edited by
                                      #117

                                      Sunny Ahuwanya wrote:

                                      non-portable, non object oriented manner

                                      Hmm, that's interesting. Is it not part of the ECMA spec? Considering there's no runtime support required for extension methods, I can't see any other portability concerns. Or maybe you are considering them non-portable because the calling code won't compile without the presence of the source code containing the extension methods? And yeah, they are non object oriented if you consider static methods in a static class non-object oriented as well.

                                      Regards Senthil [MVP - Visual C#] _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro

                                      S J 2 Replies Last reply
                                      0
                                      • J Jamie Nordmeyer

                                        So now that C# 4.0 is being talked about, I was wondering what people thought would be good additions to the language. Sorry if this is a repost, but I went through several pages, and didn't see anything, so... What I'd frankly love to see would be tuples. Rather than having to use multiple 'out' parameters, you'd just return multiple values:

                                        public int,int MinMax(int[] numbers)
                                        {
                                        int min, max;
                                        // Code to calculate min/max

                                        return min, max;
                                        }

                                        What do you think? What would be good for the next version?

                                        Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan Portland, Oregon, USA

                                        D Offline
                                        D Offline
                                        ddoutel
                                        wrote on last edited by
                                        #118

                                        I don't know what I'd put in, but I know what I'd 'take out'. I'd restrict the use of the 'var' keyword to the Linq domain, only. I see major abuse coming, and I don't relish maintaining code which uses the 'var' keyword in a profligate fashion. D. T. Doutel

                                        P 1 Reply Last reply
                                        0
                                        • J Jamie Nordmeyer

                                          So now that C# 4.0 is being talked about, I was wondering what people thought would be good additions to the language. Sorry if this is a repost, but I went through several pages, and didn't see anything, so... What I'd frankly love to see would be tuples. Rather than having to use multiple 'out' parameters, you'd just return multiple values:

                                          public int,int MinMax(int[] numbers)
                                          {
                                          int min, max;
                                          // Code to calculate min/max

                                          return min, max;
                                          }

                                          What do you think? What would be good for the next version?

                                          Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan Portland, Oregon, USA

                                          B Offline
                                          B Offline
                                          bwilhite
                                          wrote on last edited by
                                          #119

                                          Design by Contract. There's support for it in one of those little extra languages that they fiddle around with, but I'd like to see support (language-level? just a library?) for it in C#.

                                          J 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