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

C# doubt

Scheduled Pinned Locked Moved The Lounge
csharp
53 Posts 28 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.
  • M Marc Clifton

    Because params is an array of undetermined length. If you write: void Foo(params int[] ints) and try to call it with: Foo(1, 2, 3, 4) How would it know that you want 4 as a separate argument, if the method were defined like this: void Foo(params int[] oneThroughThree, int fourth) OK, maybe it could use type information, but that leads to bottomless pits where the Wumpus will eat you. Marc

    Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project!

    P Offline
    P Offline
    Pete Zahir
    wrote on last edited by
    #37

    Great, thanks

    D 1 Reply Last reply
    0
    • D Dave Kreskowiak

      Homework Marc. You're doing his homework for him.

      A guide to posting questions on CodeProject

      Click this: Asking questions is a skill. Seriously, do it.
      Dave Kreskowiak

      M Offline
      M Offline
      Marc Clifton
      wrote on last edited by
      #38

      Dave Kreskowiak wrote:

      Homework Marc. You're doing his homework for him.

      Oh well. :sigh: Marc

      Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project!

      1 Reply Last reply
      0
      • P Pete Zahir

        Explain in your own words why you cannot pass additional arguments in a function after using the params keyword.

        realJSOPR Online
        realJSOPR Online
        realJSOP
        wrote on last edited by
        #39

        Harbie wrote:

        Explain in your own words why you cannot pass additional arguments in a function after using the params keyword.

        The lily Abruptly changing The orange, having changed already Moon pie. (I certify that these are my own words.)

        ".45 ACP - because shooting twice is just silly" - JSOP, 2010
        -----
        You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
        -----
        When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

        1 Reply Last reply
        0
        • S Sascha Lefevre

          I realised I was "helping" you with an assignment which actually was the opposite of helping - because it made thinking on your part unneccessary. Help should be given in a way that pushes the learner into the right direction, lifting confusion, but not presenting the answer right away. Confucius is attributed to have said: Tell me and I forget Show me and I remember Let me do it and I understand. If you have trouble with an assignment, don't ask for the answer. Try to make it clear to yourself why you can't answer it and ask people to help you better understand the assignment so that you can answer it yourself.

          If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

          R Offline
          R Offline
          RedDk
          wrote on last edited by
          #40

          :thumbsdown: ... you because you're teaching him ...

          S 1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            :thumbsup:

            Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

            R Offline
            R Offline
            RedDk
            wrote on last edited by
            #41

            :thumbsdown: ... and you because you're not teaching him ...

            1 Reply Last reply
            0
            • P Pete Zahir

              Great, thanks

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #42

              What part of "in YOUR own words" do you not understand? When the tests come around do you get to go on the 'net and ask people for the answers? Congratulations on failing your class!

              A guide to posting questions on CodeProject

              Click this: Asking questions is a skill. Seriously, do it.
              Dave Kreskowiak

              1 Reply Last reply
              0
              • R RedDk

                :thumbsdown: ... you because you're teaching him ...

                S Offline
                S Offline
                Sascha Lefevre
                wrote on last edited by
                #43

                Don't get it!?

                If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

                R 1 Reply Last reply
                0
                • S Sascha Lefevre

                  Don't get it!?

                  If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

                  R Offline
                  R Offline
                  RedDk
                  wrote on last edited by
                  #44

                  (buzzer "eehhnn") No, we're sorry, wrong answer! (we were looking for a question "which of these thumbs is on the DARK SIDE?") :suss:

                  S 1 Reply Last reply
                  0
                  • P Pete Zahir

                    Explain in your own words why you cannot pass additional arguments in a function after using the params keyword.

                    K Offline
                    K Offline
                    Kevin Marois
                    wrote on last edited by
                    #45

                    Here you go[^]

                    If it's not broken, fix it until it is

                    1 Reply Last reply
                    0
                    • M Marc Clifton

                      Because params is an array of undetermined length. If you write: void Foo(params int[] ints) and try to call it with: Foo(1, 2, 3, 4) How would it know that you want 4 as a separate argument, if the method were defined like this: void Foo(params int[] oneThroughThree, int fourth) OK, maybe it could use type information, but that leads to bottomless pits where the Wumpus will eat you. Marc

                      Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project!

                      G Offline
                      G Offline
                      Gary Wheeler
                      wrote on last edited by
                      #46

                      Nice try, but

                      void Foo(params int[] oneThroughThree, int fourth)

                      would need to be called like this:

                      Foo(new int[] {1,2,3},4);

                      would it not?

                      Software Zen: delete this;

                      1 Reply Last reply
                      0
                      • R RedDk

                        (buzzer "eehhnn") No, we're sorry, wrong answer! (we were looking for a question "which of these thumbs is on the DARK SIDE?") :suss:

                        S Offline
                        S Offline
                        Sascha Lefevre
                        wrote on last edited by
                        #47

                        I didn't know I was participating in a quiz - instead my response was intended to tell you that I don't understand your apparent criticism of my reponse to the OP. Care to elaborate?

                        If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

                        R 1 Reply Last reply
                        0
                        • P Pete Zahir

                          Explain in your own words why you cannot pass additional arguments in a function after using the params keyword.

                          V Offline
                          V Offline
                          Vark111
                          wrote on last edited by
                          #48

                          I bet Jon Skeet can have additional arguments after a params arg.

                          1 Reply Last reply
                          0
                          • S Sascha Lefevre

                            I didn't know I was participating in a quiz - instead my response was intended to tell you that I don't understand your apparent criticism of my reponse to the OP. Care to elaborate?

                            If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

                            R Offline
                            R Offline
                            RedDk
                            wrote on last edited by
                            #49

                            Well, It's just that quoting Con-fu-dse is a little like quoting Russell then refering to "common useage" as if Russell hadn't footnoted him in using the word "common". This is the Lounge, by the way. Did I get that wrong? Looks like the Lounge anyway.

                            1 Reply Last reply
                            0
                            • P Pete Zahir

                              Explain in your own words why you cannot pass additional arguments in a function after using the params keyword.

                              R Offline
                              R Offline
                              RedDk
                              wrote on last edited by
                              #50

                              The VBA interface doesn't allow it.

                              1 Reply Last reply
                              0
                              • D Duncan Edwards Jones

                                Squay mmem os pippk* (* These are my own words but I don't see how anyone else will be able to understand them)

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

                                I was wondering who summoned our great lord Cthulhu!

                                Read my (free) ebook Object-Oriented Programming in C# Succinctly. Visit my blog at Sander's bits - Writing the code you need. Or read my articles here on CodeProject.

                                Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

                                Regards, Sander

                                1 Reply Last reply
                                0
                                • P Pete Zahir

                                  Explain in your own words why you cannot pass additional arguments in a function after using the params keyword.

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

                                  Because if you could you wouldn't have homework to do.

                                  Read my (free) ebook Object-Oriented Programming in C# Succinctly. Visit my blog at Sander's bits - Writing the code you need. Or read my articles here on CodeProject.

                                  Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

                                  Regards, Sander

                                  1 Reply Last reply
                                  0
                                  • P Pete Zahir

                                    Explain in your own words why you cannot pass additional arguments in a function after using the params keyword.

                                    L Offline
                                    L Offline
                                    Leng Vang
                                    wrote on last edited by
                                    #53

                                    Not sure how C# implement that, but I'm guessing it has to do with how the arguments are push onto a stack before a function address is invoked. Being that the stack doesn't have anything to manage what type each parameter are and the Parameter type can be any number of arguments, making it difficult to separate the actual arguments from the Parameter ones.

                                    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