doubt

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

    doubt

    Hi,

    Please let me know, In c-sharp, it's possible to use the Same method for
    using multiple purpose ie Sending More than one Parameter, or Parameter with
    different type etc without Overloading...


  • William Ryan

    #2
    Re: doubt

    No.

    In vb.net you have the attrocious scourge aka optional parameters, but C#
    doesn't let you do that.

    If you really have a good reason to not overload, then you could pass in a
    struct or object and based on it's properties branch off into different
    segments, which would effectively accomplish what you want, but it would be
    much more complex than a simple overload.

    If you don't mind me asking...why are you ambivalent about overloading?
    (Not being argumentative, just curious.)

    Bill
    "Baskar RajaSekharan" <rbk@srasys.co. in> wrote in message
    news:OP64tW2oDH A.2140@TK2MSFTN GP09.phx.gbl...[color=blue]
    > Hi,
    >
    > Please let me know, In c-sharp, it's possible to use the Same method[/color]
    for[color=blue]
    > using multiple purpose ie Sending More than one Parameter, or Parameter[/color]
    with[color=blue]
    > different type etc without Overloading...
    >
    >[/color]


    Comment

    • Fred Mellender

      #3
      Re: doubt

      You could do what Invoke does: pass an array of Objects. You can query the
      array to find out its size and branch based on the type of the parameters.

      "Baskar RajaSekharan" <rbk@srasys.co. in> wrote in message
      news:OP64tW2oDH A.2140@TK2MSFTN GP09.phx.gbl...[color=blue]
      > Hi,
      >
      > Please let me know, In c-sharp, it's possible to use the Same method[/color]
      for[color=blue]
      > using multiple purpose ie Sending More than one Parameter, or Parameter[/color]
      with[color=blue]
      > different type etc without Overloading...
      >
      >[/color]


      Comment

      • Tom Clement

        #4
        Re: doubt

        Take a look at parameter arrays (params keyword). That lets you pass in
        multiple arguments of a specified type. If you want different types and
        different numbers of arguments, that's exactly what function overloading is
        for.

        Tom Clement
        Apptero, Inc.

        "Baskar RajaSekharan" <rbk@srasys.co. in> wrote in message
        news:OP64tW2oDH A.2140@TK2MSFTN GP09.phx.gbl...[color=blue]
        > Hi,
        >
        > Please let me know, In c-sharp, it's possible to use the Same method[/color]
        for[color=blue]
        > using multiple purpose ie Sending More than one Parameter, or Parameter[/color]
        with[color=blue]
        > different type etc without Overloading...
        >
        >[/color]


        Comment

        Working...