Results 1 to 11 of 11

Thread: how to make a vb's "optional" in a function

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    how to make a vb's "optional" in a function

    how do i make that in c#?
    \m/\m/

  2. #2
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539
    as far as i am aware of this feature its not available...
    but there is a better way

    overload the function

    private void func1(int blah)
    {
    }

    private void func1()
    {
    }

  3. #3

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    bah ..
    \m/\m/

  4. #4
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539
    function overloading is much better of course
    optional parameters are for wussies

  5. #5

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    imagine i have a function with 100 lines(well it has only 4 but it could have more ) and i want 2paramenters to be optional..then i'd instead of having 100 lines of code have 300 lines..its a bit much no? lol
    \m/\m/

  6. #6
    Addicted Member MasterBlaster's Avatar
    Join Date
    Jul 2002
    Location
    Seattle
    Posts
    196
    private void func1(int blah)
    {
    My200LinesoCode(blah)

    }

    private void func1()
    {
    My200LinesofCode(0)
    }

    private void My200LinesofCode(int blahblah)
    {
    }

    This is how I get around it. In the second overload just call your real code and pass whatever you wanted the optional default value to be. Hope this helps.
    Last edited by MasterBlaster; Nov 22nd, 2002 at 06:07 PM.

  7. #7

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    tks ive already though of that
    \m/\m/

  8. #8
    Addicted Member MasterBlaster's Avatar
    Join Date
    Jul 2002
    Location
    Seattle
    Posts
    196
    "Well Heeelllooo Mr Fancy Pants!"

  9. #9

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    . . .
    \m/\m/

  10. #10
    Addicted Member MasterBlaster's Avatar
    Join Date
    Jul 2002
    Location
    Seattle
    Posts
    196
    Sorry, I rented the Movie "Army Of Darkness" that day and have been spewing out cheesey lines from it all weekend.

  11. #11

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    uuuuuuu im scared
    \m/\m/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width