Doubt

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

    Doubt

    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




  • Yura2000

    #2
    Doubt

    There is sample from MSDN:

    public static void UseParams2(para ms object[] list)
    {
    for ( int i = 0 ; i < list.Length ; i++ )
    Console.WriteLi ne(list[i]);
    Console.WriteLi ne();
    }

    public static void Main()
    {
    UseParams2(1, 'a', "test");

    }


    Good luck[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
    >
    >
    >
    >
    >.
    >[/color]

    Comment

    • 100

      #3
      Re: Doubt

      Hi Yura2000,

      I believe this example is for variable number of arguments rather than
      default parameters. Without overloading you cannot accomplish this in c#.

      B\rgds
      100

      "Yura2000" <yurig@clal-ins.co.il> wrote in message
      news:055b01c3a9 26$02311b90$a00 1280a@phx.gbl.. .[color=blue]
      > There is sample from MSDN:
      >
      > public static void UseParams2(para ms object[] list)
      > {
      > for ( int i = 0 ; i < list.Length ; i++ )
      > Console.WriteLi ne(list[i]);
      > Console.WriteLi ne();
      > }
      >
      > public static void Main()
      > {
      > UseParams2(1, 'a', "test");
      >
      > }
      >
      >
      > Good luck[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
      > >
      > >
      > >
      > >
      > >.
      > >[/color][/color]


      Comment

      • Alvin Bruney

        #4
        Re: Doubt

        default parameter passing is not support in C#. What is your concern for not
        using overloading, because this is probably your best option?

        --


        -----------
        Got TidBits?
        Get it here: www.networkip.net/tidbits
        "Baskar RajaSekharan" <rbk@srasys.co. in> wrote in message
        news:eianjZRqDH A.3688@TK2MSFTN GP11.phx.gbl...[color=blue]
        > 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
        >
        >
        >
        >[/color]


        Comment

        • 100

          #5
          Re: Doubt

          This is the only option :-( I would say.

          B\rgds
          100

          "Alvin Bruney" <vapordan_spam_ me_not@hotmail_ no_spamhotmail. com> wrote in
          message news:%23HMXJ%23 TqDHA.1632@TK2M SFTNGP10.phx.gb l...[color=blue]
          > default parameter passing is not support in C#. What is your concern for[/color]
          not[color=blue]
          > using overloading, because this is probably your best option?
          >
          > --
          >
          >
          > -----------
          > Got TidBits?
          > Get it here: www.networkip.net/tidbits
          > "Baskar RajaSekharan" <rbk@srasys.co. in> wrote in message
          > news:eianjZRqDH A.3688@TK2MSFTN GP11.phx.gbl...[color=green]
          > > Hi,
          > >
          > > Please let me know is ther any way to pass some default parameters to[/color][/color]
          a[color=blue][color=green]
          > > Method in C-Sharp without overloading the Method.
          > > In VB we can done the above with the help of optional parameter .[/color][/color]
          What's[color=blue][color=green]
          > > the Equvelent in C-Sharp.
          > >
          > > Note : Without Method OverLoading.
          > >
          > > can you give me some sample.
          > >
          > > Regards,
          > > R.Baskar
          > >
          > >
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • Alvin Bruney

            #6
            Re: Doubt

            ya it is but i was being polite. :-)

            gota luv it

            --


            -----------
            Got TidBits?
            Get it here: www.networkip.net/tidbits
            "100" <100@100.com> wrote in message
            news:#IBeKFUqDH A.372@TK2MSFTNG P11.phx.gbl...[color=blue]
            > This is the only option :-( I would say.
            >
            > B\rgds
            > 100
            >
            > "Alvin Bruney" <vapordan_spam_ me_not@hotmail_ no_spamhotmail. com> wrote in
            > message news:%23HMXJ%23 TqDHA.1632@TK2M SFTNGP10.phx.gb l...[color=green]
            > > default parameter passing is not support in C#. What is your concern for[/color]
            > not[color=green]
            > > using overloading, because this is probably your best option?
            > >
            > > --
            > >
            > >
            > > -----------
            > > Got TidBits?
            > > Get it here: www.networkip.net/tidbits
            > > "Baskar RajaSekharan" <rbk@srasys.co. in> wrote in message
            > > news:eianjZRqDH A.3688@TK2MSFTN GP11.phx.gbl...[color=darkred]
            > > > Hi,
            > > >
            > > > Please let me know is ther any way to pass some default parameters[/color][/color][/color]
            to[color=blue]
            > a[color=green][color=darkred]
            > > > Method in C-Sharp without overloading the Method.
            > > > In VB we can done the above with the help of optional parameter .[/color][/color]
            > What's[color=green][color=darkred]
            > > > the Equvelent in C-Sharp.
            > > >
            > > > Note : Without Method OverLoading.
            > > >
            > > > can you give me some sample.
            > > >
            > > > Regards,
            > > > R.Baskar
            > > >
            > > >
            > > >
            > > >[/color]
            > >
            > >[/color]
            >
            >[/color]


            Comment

            Working...