clarification is needed

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Baskar RajaSekharan

    clarification is needed

    Hi,

    Please let me know is ther any way to pass some default parameters to a
    Method in C-Sharp without overloading the Method.
    In VB we can done the above with the help of optional parameter . What's
    the Equvelent in C-Sharp.

    Note : Without Method OverLoading.

    can you give me some sample.

    Regards,
    R.Baskar


    c


  • Guest's Avatar

    #2
    clarification is needed

    What's the problem with method overloading ?
    Actually, it's the only solution.
    The framework does it all over the place.
    You don't have to worry about the extra method and extra
    method call.

    Greetings,
    BV.

    [color=blue]
    >-----Original Message-----
    >Hi,
    >
    > Please let me know is ther any way to pass some[/color]
    default parameters to a[color=blue]
    >Method in C-Sharp without overloading the Method.
    >In VB we can done the above with the help of optional[/color]
    parameter . What's[color=blue]
    >the Equvelent in C-Sharp.
    >
    >Note : Without Method OverLoading.
    >
    >can you give me some sample.
    >
    >Regards,
    >R.Baskar
    >
    >
    >c
    >
    >
    >.
    >[/color]

    Comment

    • 100

      #3
      Re: clarification is needed

      I's too boring. If I have method and I want to have for say 3 of the
      parameters default values I have to make 3 dummy overloads. Those overloads
      pollute the code and make the source files bigger.
      It's a shame that c# doesn't have default parameters. I don't warry about
      the performance hopefully calls to those methods will be inlined by the
      JITter.
      I think default parametters are not CLI compliant, but we may still benefit
      from them for internal stuff.

      B\rgds
      100

      <anonymous@disc ussions.microso ft.com> wrote in message
      news:049b01c3a9 1b$e0d93bd0$a00 1280a@phx.gbl.. .[color=blue]
      > What's the problem with method overloading ?
      > Actually, it's the only solution.
      > The framework does it all over the place.
      > You don't have to worry about the extra method and extra
      > method call.
      >
      > Greetings,
      > BV.
      >
      >[color=green]
      > >-----Original Message-----
      > >Hi,
      > >
      > > Please let me know is ther any way to pass some[/color]
      > default parameters to a[color=green]
      > >Method in C-Sharp without overloading the Method.
      > >In VB we can done the above with the help of optional[/color]
      > parameter . What's[color=green]
      > >the Equvelent in C-Sharp.
      > >
      > >Note : Without Method OverLoading.
      > >
      > >can you give me some sample.
      > >
      > >Regards,
      > >R.Baskar
      > >
      > >
      > >c
      > >
      > >
      > >.
      > >[/color][/color]


      Comment

      • Zürcher See

        #4
        Re: clarification is needed

        Make a struct with the parameters and pass the struct to your method

        "100" <100@100.com> schrieb im Newsbeitrag
        news:uBdoVwSqDH A.2940@TK2MSFTN GP09.phx.gbl...[color=blue]
        > I's too boring. If I have method and I want to have for say 3 of the
        > parameters default values I have to make 3 dummy overloads. Those[/color]
        overloads[color=blue]
        > pollute the code and make the source files bigger.
        > It's a shame that c# doesn't have default parameters. I don't warry about
        > the performance hopefully calls to those methods will be inlined by the
        > JITter.
        > I think default parametters are not CLI compliant, but we may still[/color]
        benefit[color=blue]
        > from them for internal stuff.
        >
        > B\rgds
        > 100
        >
        > <anonymous@disc ussions.microso ft.com> wrote in message
        > news:049b01c3a9 1b$e0d93bd0$a00 1280a@phx.gbl.. .[color=green]
        > > What's the problem with method overloading ?
        > > Actually, it's the only solution.
        > > The framework does it all over the place.
        > > You don't have to worry about the extra method and extra
        > > method call.
        > >
        > > Greetings,
        > > BV.
        > >
        > >[color=darkred]
        > > >-----Original Message-----
        > > >Hi,
        > > >
        > > > Please let me know is ther any way to pass some[/color]
        > > default parameters to a[color=darkred]
        > > >Method in C-Sharp without overloading the Method.
        > > >In VB we can done the above with the help of optional[/color]
        > > parameter . What's[color=darkred]
        > > >the Equvelent in C-Sharp.
        > > >
        > > >Note : Without Method OverLoading.
        > > >
        > > >can you give me some sample.
        > > >
        > > >Regards,
        > > >R.Baskar
        > > >
        > > >
        > > >c
        > > >
        > > >
        > > >.
        > > >[/color][/color]
        >
        >[/color]


        Comment

        • 100

          #5
          Re: clarification is needed

          Hi,
          No, struct won't do. Why?
          1. This is not what we want to do. It makes the code unclear. I don't have
          method with default parameters. What I have is method with a mandatory
          parameter of some struct type .
          2. I can't have default values for the structure fields, because I can't
          have a default constructor (thus I can't have initializing expressions in
          the fields' declarations) . Because of the latter I have to make as many
          overloads of that structure's constructor as many defaults parameters I
          have. So, where is the benefit?. Better to overload my method.

          Classes doesn't have these disadvantages, but classes are reference types,
          which opposites the nature of the parameters, which are local copies of the
          actual ones passed to the function.

          Again, why we have to workaround something which has to be feature of any
          modern language I believe?

          B\rgds
          100

          "Zürcher See" <aquila@cannabi smail.com> wrote in message
          news:1068719068 .481963@fuchs.c yberlink.ch...[color=blue]
          > Make a struct with the parameters and pass the struct to your method
          >
          > "100" <100@100.com> schrieb im Newsbeitrag
          > news:uBdoVwSqDH A.2940@TK2MSFTN GP09.phx.gbl...[color=green]
          > > I's too boring. If I have method and I want to have for say 3 of the
          > > parameters default values I have to make 3 dummy overloads. Those[/color]
          > overloads[color=green]
          > > pollute the code and make the source files bigger.
          > > It's a shame that c# doesn't have default parameters. I don't warry[/color][/color]
          about[color=blue][color=green]
          > > the performance hopefully calls to those methods will be inlined by the
          > > JITter.
          > > I think default parametters are not CLI compliant, but we may still[/color]
          > benefit[color=green]
          > > from them for internal stuff.
          > >
          > > B\rgds
          > > 100
          > >
          > > <anonymous@disc ussions.microso ft.com> wrote in message
          > > news:049b01c3a9 1b$e0d93bd0$a00 1280a@phx.gbl.. .[color=darkred]
          > > > What's the problem with method overloading ?
          > > > Actually, it's the only solution.
          > > > The framework does it all over the place.
          > > > You don't have to worry about the extra method and extra
          > > > method call.
          > > >
          > > > Greetings,
          > > > BV.
          > > >
          > > >
          > > > >-----Original Message-----
          > > > >Hi,
          > > > >
          > > > > Please let me know is ther any way to pass some
          > > > default parameters to a
          > > > >Method in C-Sharp without overloading the Method.
          > > > >In VB we can done the above with the help of optional
          > > > parameter . What's
          > > > >the Equvelent in C-Sharp.
          > > > >
          > > > >Note : Without Method OverLoading.
          > > > >
          > > > >can you give me some sample.
          > > > >
          > > > >Regards,
          > > > >R.Baskar
          > > > >
          > > > >
          > > > >c
          > > > >
          > > > >
          > > > >.
          > > > >[/color]
          > >
          > >[/color]
          >
          >[/color]


          Comment

          Working...