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 449 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 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
    Bastian M K Ohta
    wrote on last edited by
    #75

    I'd like to have local static varibles.

    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
      ASMiller
      wrote on last edited by
      #76

      How about the ability to partially set array values. For example, for an int array of length 10 with default values of 0..9 respectively, the following would be valid:

      myArray[3..5] = (-3, -4, -5);

      The contents would then be: 0, 1, 2, -3, -4, -5, 6, 7, 8, 9 Another idea is a composite Label (say Strings and Images). The display of CompositeLabel.Text would display a String followed by an Image then we could have things (using my mythical System.Text.SmileyFace namespace) like . . .

      myCompositeLabel.Text = "Hello, World " + System.Text.SmileyFace.BigGrin.ToImage();

      The display would then be: Hello, World :-D Anthony

      P 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

        A Offline
        A Offline
        alan cooper
        wrote on last edited by
        #77

        I bet 99% of you disagree with this one! I would like to see multiple inheritance and full operator overloading available in C#.

        R P 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

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

          I believe this is a programming question! :mad:

          J 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.

            H Offline
            H Offline
            higelino
            wrote on last edited by
            #79

            The good answer to 'constness' is spec#. The 'constness', the 'nonnullness', the 'checkedexceptionness' , the 'immutabilityness' etc ... are all describable with contracts. I think Spec# will be a real revolution in the .NET world. In fact the .NET infrastructure should evolve to include contract metadata so that every .NET language will manage contracts in a similar way. Try it here http://research.microsoft.com/SpecSharp/[^] ... and cry because I am sure that c#4 won't include spec# :-(

            K 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

              T Offline
              T Offline
              ThunderDK
              wrote on last edited by
              #80

              I think it would be easier to just make it an array of the two ints instead. How would you receive the values from the method call?

              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

                R Offline
                R Offline
                RugbyLeague
                wrote on last edited by
                #81

                an IMaths interface so writing maths libraries with generics is simpler

                1 Reply Last reply
                0
                • C Christian Graus

                  Because if you're providing an interface, you provide a contract with the people who use that interface. If I write a library, I can use const to tell a user when they can trust my code not to change their stuff.

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

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

                  Christian Graus wrote:

                  I can use const to tell a user when they can trust my code not to change their stuff.

                  erm, I don't see how that would work. I thought that const was more of a promise to yourself, or to implementors, not to users. Nothing prevents you from calling methods and setting fields, right? Ok, let me start it again. What is the const keyword supposed to do in parameters that has an effect outside the method?

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

                  J 1 Reply Last reply
                  0
                  • J Jamie Nordmeyer

                    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 Offline
                    M Offline
                    Mel Padden
                    wrote on last edited by
                    #83

                    That's the best and most practical suggestion for c# I've seen. has anybody raised it to MS?

                    Smokie, this is not 'Nam. This is bowling. There are rules. www.geticeberg.com

                    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

                      R Offline
                      R Offline
                      Russell Jones
                      wrote on last edited by
                      #84

                      I do sort of like the idea but isn't a function by definition a thing that only returns a single value? Maybe we need anonymous returns instead so that you define a struct on the fly, thus returning a single entity that contains the multiple values. public {Max int, Min int} MinMax(int[] numbers) { int min, max; // Code to calculate min/max return {min, max}; } called with var v= MinMax(myArray); system.out.println(v.Min); system.out.println(v.Max); otherwise you'd end up having to create something wierd like this to get the values back int min, max = MinMax(myArray); Russell

                      J 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.

                        O Offline
                        O Offline
                        Oshtri Deka
                        wrote on last edited by
                        #85

                        Hallelujah!

                        1 Reply Last reply
                        0
                        • C Christian Graus

                          Yeah, the C# team explicitly stated they always try to make the language simple rather than powerful. Which is retarded IMO. Sure, you can make mistakes with powerful features, but that's not the point.

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

                          D Offline
                          D Offline
                          Don Miguel
                          wrote on last edited by
                          #86

                          Christian Graus wrote:

                          they always try to make the language simple

                          Indeed, C# is a simple language, and was build exactly with this in mind. To be simple. Why now we just ask for features which belongs to higher level languages? Let it simple. For complex things, use C/C++. For critical and low level, use assembler. For functional use F#. And so on. Is it like we ask for VB to have some super features, which were never supposed to be in a programming language addressing the "features" VB address...

                          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

                            O Offline
                            O Offline
                            Oshtri Deka
                            wrote on last edited by
                            #87

                            As I posted before, I agree with Ennis Ray Lynch, Jr. that programmers should first learn all features of .Net 2.0 before jumping on new and shiny stuff. I would personally like to see static interfaces and inheritance from multiple classes.

                            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

                              D Offline
                              D Offline
                              Don Miguel
                              wrote on last edited by
                              #88

                              Well, I'll be satisfied if C# will become sometime, in the future, as good as Java already is today... ;P

                              1 Reply Last reply
                              0
                              • S Sunny Ahuwanya

                                Actually, foreach is needed. Without foreach, you can't guarantee that the Enumerable pattern is followed. You don't expect developers to consistently follow the pattern using a for or while loop.

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

                                R Offline
                                R Offline
                                Russell Jones
                                wrote on last edited by
                                #89

                                Surely without foreach you'd just be in the same position as Java was (pre v1.5?) where you have to make a call to getIterator() and then loop through that. It's much more unfriendly than foreach but it still does the same thing Russ

                                1 Reply Last reply
                                0
                                • J Jamie Nordmeyer

                                  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

                                  U Offline
                                  U Offline
                                  User 4641568
                                  wrote on last edited by
                                  #90

                                  hm.. sexy!

                                  1 Reply Last reply
                                  0
                                  • A alan cooper

                                    I bet 99% of you disagree with this one! I would like to see multiple inheritance and full operator overloading available in C#.

                                    R Offline
                                    R Offline
                                    Rocky Moore
                                    wrote on last edited by
                                    #91

                                    Ditto! While I seldom use multiple inheritance, it still would be great to have it availble for those times that I do.

                                    Rocky <>< Recent Blog Post: Netflix Gets Starz!

                                    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

                                      R Offline
                                      R Offline
                                      Rocky Moore
                                      wrote on last edited by
                                      #92

                                      Yep, that would be handy!

                                      Rocky <>< Recent Blog Post: Netflix Gets Starz!

                                      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

                                        S Offline
                                        S Offline
                                        SlingBlade
                                        wrote on last edited by
                                        #93

                                        How about a way to check against all values in an array or enumerabale at once with perhaps the keyword 'any' like below.

                                        int[] supportedValues = new int[] { 3, 4, 5 }
                                        int x = 4;

                                        if (x == any supportedValues)
                                        {
                                        // Do something.
                                        }

                                        Instead of:

                                        int[] supportedValues = new int[] { 3, 4, 5 }
                                        int x = 4;
                                        bool xIsSupported = false;

                                        foreach (int value in supportedValues)
                                        {
                                        if (x == value)
                                        xIsSupported = true;
                                        }

                                        if (xIsSupported)
                                        {
                                        // Do something.
                                        }

                                        Good idea?

                                        B P S J 4 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

                                          M Offline
                                          M Offline
                                          Maximus014
                                          wrote on last edited by
                                          #94

                                          Can anyone say partial properties? Being able to add attributes to properties created in generated code would be awesome (using a the MetadataType approach is such an ugly hack). I would also love to be able to add extension methods to a static class. I know everyone has wanted to add some functionality to Membership or Math.

                                          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