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 427 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.
  • J Offline
    J Offline
    Jamie Nordmeyer
    wrote on last edited by
    #1

    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

    E C P T M 48 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

      E Offline
      E Offline
      Ennis Ray Lynch Jr
      wrote on last edited by
      #2

      The Powers Collection or a simple hand rolled generic handles tuples, Pair<int, int> I have always said that developers need to focus on mastering what has been provided in 2.0 before even thinking about adding more candy.

      Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
      Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
      Most of this sig is for Google, not ego.

      J T O 3 Replies Last reply
      0
      • E Ennis Ray Lynch Jr

        The Powers Collection or a simple hand rolled generic handles tuples, Pair<int, int> I have always said that developers need to focus on mastering what has been provided in 2.0 before even thinking about adding more candy.

        Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
        Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
        Most of this sig is for Google, not ego.

        J Offline
        J Offline
        Jamie Nordmeyer
        wrote on last edited by
        #3

        And I agree. Learn how to use what you have first. And I've used the Pair object before. But being able to specify a list of return values would be nice. Not necessary, no. But nice. The same thing could be said for the ?? operator though. Do you need it? No. But it's definitely nice! :)

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

        C S 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

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          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.

          J D L T N 15 Replies 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.

            J Offline
            J Offline
            Jamie Nordmeyer
            wrote on last edited by
            #5

            here here!

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

            C G A 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

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

              Jamie Nordmeyer wrote:

              C# 4.0

              I haven't heard anything about it.

              Jamie Nordmeyer wrote:

              return min, max;

              That syntax wouldn't be a good choice, because of the comma operator. I would just return an array of int. Though the only place I do that is a routine that parses a string to get a latitude and longitude (doubles in this case).

              J R 2 Replies Last reply
              0
              • J Jamie Nordmeyer

                And I agree. Learn how to use what you have first. And I've used the Pair object before. But being able to specify a list of return values would be nice. Not necessary, no. But nice. The same thing could be said for the ?? operator though. Do you need it? No. But it's definitely nice! :)

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

                C Offline
                C Offline
                Christian Graus
                wrote on last edited by
                #7

                I'd love to be able to check if say, myObject was null and if it was, return a result, and if not, return a property of myObject using the ?? operator.

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

                E J S 3 Replies 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.

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

                  Why const? What will it even do besides limit the programmer in the usage of said parameters?

                  C L M I 4 Replies 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.

                    D Offline
                    D Offline
                    DaveyM69
                    wrote on last edited by
                    #9

                    Christian Graus wrote:

                    optional parameters

                    Ditto - one of the few things that I prefer in VB.NET. Creating loads of overloads is a royal PITA.

                    Dave
                    BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
                    Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

                    C 1 Reply Last reply
                    0
                    • J Jamie Nordmeyer

                      here here!

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

                      C Offline
                      C Offline
                      Christian Graus
                      wrote on last edited by
                      #10

                      I put these things to the C# team at least twice, and they appeared too stupid to understand why they were of value.

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

                      1 Reply Last reply
                      0
                      • P PIEBALDconsult

                        Jamie Nordmeyer wrote:

                        C# 4.0

                        I haven't heard anything about it.

                        Jamie Nordmeyer wrote:

                        return min, max;

                        That syntax wouldn't be a good choice, because of the comma operator. I would just return an array of int. Though the only place I do that is a routine that parses a string to get a latitude and longitude (doubles in this case).

                        J Offline
                        J Offline
                        Jamie Nordmeyer
                        wrote on last edited by
                        #11

                        PIEBALDconsult wrote:

                        That syntax wouldn't be a good choice, because of the comma operator.

                        It'd certainly take some work on the part of the parser developers at Microsoft, but it'd still be useful in my humble opinion. What if I wanted to return an integer, 2 strings, and a DateTime? Today, I'd just use a struct or out parameters. Easy enough. It'd just be NICE to be able to return everything. Like the ?? operator. Not necessary, but still useful. Again, just my humble opinion. :)

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

                        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.

                          T Offline
                          T Offline
                          ToddHileHoffer
                          wrote on last edited by
                          #12

                          Good ideas. Have you suggested them to MS?

                          I didn't get any requirements for the signature

                          C 1 Reply Last reply
                          0
                          • C Christian Graus

                            I'd love to be able to check if say, myObject was null and if it was, return a result, and if not, return a property of myObject using the ?? operator.

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

                            E Offline
                            E Offline
                            Ennis Ray Lynch Jr
                            wrote on last edited by
                            #13

                            Wait, that may have come out wrong but that is something I really would love to have.

                            Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
                            Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
                            Most of this sig is for Google, not ego.

                            1 Reply Last reply
                            0
                            • E Ennis Ray Lynch Jr

                              The Powers Collection or a simple hand rolled generic handles tuples, Pair<int, int> I have always said that developers need to focus on mastering what has been provided in 2.0 before even thinking about adding more candy.

                              Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
                              Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
                              Most of this sig is for Google, not ego.

                              T Offline
                              T Offline
                              Todd Smith
                              wrote on last edited by
                              #14

                              Ennis Ray Lynch, Jr. wrote:

                              I have always said that developers need to focus on mastering what has been provided in 2.0 before even thinking about adding more candy.

                              Would it really be hard to "master" tuples as a return paramter? I love that feature as part of LUA and Python especially over out parametes. Spec# sounds interesting which adds support for explicit programming by contract.

                              Todd Smith

                              E K 2 Replies Last reply
                              0
                              • L Lost User

                                Why const? What will it even do besides limit the programmer in the usage of said parameters?

                                C Offline
                                C Offline
                                Christian Graus
                                wrote on last edited by
                                #15

                                In a language where most things are passed by reference, there's even more value in an interface making an explicit promise to not alter an object that it is given to work with. How does it limit the programmer ? If you want to alter an object, don't mark it const.

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

                                L 1 Reply Last reply
                                0
                                • C Christian Graus

                                  I'd love to be able to check if say, myObject was null and if it was, return a result, and if not, return a property of myObject using the ?? operator.

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

                                  J Offline
                                  J Offline
                                  Jamie Nordmeyer
                                  wrote on last edited by
                                  #16

                                  I saw someone comment on that on another forum. Basically, you'd have something like this (using his sample syntax):

                                  int? x = Company?.Person["Bob"]?.Age;

                                  If Company or Company.Person["Bob"] were null, then x would be set to null, rather than getting an exception. I likes.

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

                                  M U C K 5 Replies Last reply
                                  0
                                  • D DaveyM69

                                    Christian Graus wrote:

                                    optional parameters

                                    Ditto - one of the few things that I prefer in VB.NET. Creating loads of overloads is a royal PITA.

                                    Dave
                                    BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
                                    Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

                                    C Offline
                                    C Offline
                                    Christian Graus
                                    wrote on last edited by
                                    #17

                                    Yes, it's something the compiler could easily do for you.

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

                                    D 1 Reply Last reply
                                    0
                                    • T ToddHileHoffer

                                      Good ideas. Have you suggested them to MS?

                                      I didn't get any requirements for the signature

                                      C Offline
                                      C Offline
                                      Christian Graus
                                      wrote on last edited by
                                      #18

                                      Twice, yes. Both times the C# team argued about the complexity of introducing named optional params, and I said, I'm not asking for that. just some simple syntactic sugar ( the compiler can just generate the methods that pass the defaults through ). Like banging your head against a wall. Of course, now I am not an MVP, because I hate Vista, so I can't suggest anything anymore.

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

                                      M 1 Reply Last reply
                                      0
                                      • T Todd Smith

                                        Ennis Ray Lynch, Jr. wrote:

                                        I have always said that developers need to focus on mastering what has been provided in 2.0 before even thinking about adding more candy.

                                        Would it really be hard to "master" tuples as a return paramter? I love that feature as part of LUA and Python especially over out parametes. Spec# sounds interesting which adds support for explicit programming by contract.

                                        Todd Smith

                                        E Offline
                                        E Offline
                                        Ennis Ray Lynch Jr
                                        wrote on last edited by
                                        #19

                                        It is more that .NET 2.0 provide the exact construct as required to perform the action without the need for a language update. I am not saying it is hard to master but I am constantly seeing instances of persons requesting features that are already supported.

                                        Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
                                        Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
                                        Most of this sig is for Google, not ego.

                                        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.

                                          N Offline
                                          N Offline
                                          Nemanja Trifunovic
                                          wrote on last edited by
                                          #20

                                          Christian Graus wrote:

                                          optional parameters

                                          Mixing optional parameters and overloads can lead to pretty bad mess.

                                          Programming Blog utf8-cpp

                                          C Steve EcholsS 2 Replies 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