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. General Programming
  3. C#
  4. HOW TO: Pass Optional Method Arguments from C#

HOW TO: Pass Optional Method Arguments from C#

Scheduled Pinned Locked Moved C#
csharpcomtutorialquestion
7 Posts 5 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.
  • L Offline
    L Offline
    leppie
    wrote on last edited by
    #1

    http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q305814&[^] :)

    D 1 Reply Last reply
    0
    • L leppie

      http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q305814&[^] :)

      D Offline
      D Offline
      David Stone
      wrote on last edited by
      #2

      Yeah but that shows how to use it from C#. Not how to implement it in C#. :( David Stone But Clinton wasn't a predictable, boring, aging, lying, eloquent, maintainer-of-the-status-quo. He was a predictable, boring-but-trying-to-look-hip, aging-and-fat-but-seemingly-oblivious-to-it, lying-but-in-sadly-blatant-ways, not-eloquent-but-trying-to-make-up-for-it-by-talking-even-more, bringer-in-of-scary-and-potentially-dangerous-new-policies. And there was also Al Gore. It just wasn't *right*. Shog9

      N 1 Reply Last reply
      0
      • D David Stone

        Yeah but that shows how to use it from C#. Not how to implement it in C#. :( David Stone But Clinton wasn't a predictable, boring, aging, lying, eloquent, maintainer-of-the-status-quo. He was a predictable, boring-but-trying-to-look-hip, aging-and-fat-but-seemingly-oblivious-to-it, lying-but-in-sadly-blatant-ways, not-eloquent-but-trying-to-make-up-for-it-by-talking-even-more, bringer-in-of-scary-and-potentially-dangerous-new-policies. And there was also Al Gore. It just wasn't *right*. Shog9

        N Offline
        N Offline
        Nnamdi Onyeyiri
        wrote on last edited by
        #3

        thats because you cant. says so in the first paragraph. ;P


        :suss: Email: theeclypse@hotmail.com   URL: http://www.onyeyiri.co.uk
        :suss:"All programmers are playwrights and all computers are lousy actors."

        B 1 Reply Last reply
        0
        • N Nnamdi Onyeyiri

          thats because you cant. says so in the first paragraph. ;P


          :suss: Email: theeclypse@hotmail.com   URL: http://www.onyeyiri.co.uk
          :suss:"All programmers are playwrights and all computers are lousy actors."

          B Offline
          B Offline
          bfarley
          wrote on last edited by
          #4

          Not quite true. C# supports the params keyword, which allows an object[] of user-defined size to be passed as a method parameter. This could be used to implement optional args in a sense. Bill F

          N J 2 Replies Last reply
          0
          • B bfarley

            Not quite true. C# supports the params keyword, which allows an object[] of user-defined size to be passed as a method parameter. This could be used to implement optional args in a sense. Bill F

            N Offline
            N Offline
            Nnamdi Onyeyiri
            wrote on last edited by
            #5

            i suppose, but not in the same manner as in c++ which i think is better.


            :suss: Email: theeclypse@hotmail.com   URL: http://www.onyeyiri.co.uk
            :suss:"All programmers are playwrights and all computers are lousy actors."

            1 Reply Last reply
            0
            • B bfarley

              Not quite true. C# supports the params keyword, which allows an object[] of user-defined size to be passed as a method parameter. This could be used to implement optional args in a sense. Bill F

              J Offline
              J Offline
              James T Johnson
              wrote on last edited by
              #6

              bfarley wrote: in a sense Those are the key words right there.... Instead of writing a normal method and specifying default values you have to go through the array and find out which parameters go where, and lord help you if you have two parameters of the same type but only one is in the array :wtf: There are times where I like not having optional parameters because it makes the user of that code think before just accepting the defaults; other times its a real PITA. James "And we are all men; apart from the females." - Colin Davies

              B 1 Reply Last reply
              0
              • J James T Johnson

                bfarley wrote: in a sense Those are the key words right there.... Instead of writing a normal method and specifying default values you have to go through the array and find out which parameters go where, and lord help you if you have two parameters of the same type but only one is in the array :wtf: There are times where I like not having optional parameters because it makes the user of that code think before just accepting the defaults; other times its a real PITA. James "And we are all men; apart from the females." - Colin Davies

                B Offline
                B Offline
                bfarley
                wrote on last edited by
                #7

                Hey, I didn't say it was perfect - just that it could be done. Bill F

                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