Doubt

  • Thread starter Thread starter Baskar RajaSekharan
  • Start date Start date
B

Baskar RajaSekharan

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
 
There is sample from MSDN:

public static void UseParams2(params object[] list)
{
for ( int i = 0 ; i < list.Length ; i++ )
Console.WriteLine(list);
Console.WriteLine();
}

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

}


Good luck
 
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 said:
There is sample from MSDN:

public static void UseParams2(params object[] list)
{
for ( int i = 0 ; i < list.Length ; i++ )
Console.WriteLine(list);
Console.WriteLine();
}

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

}


Good luck
-----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




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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

clarification is needed 4
doubt 1
Doubt 4
Doubt 1
doubt 1
How to Erase a FileContent in c -Sarp? 7
C# Tips : Optional and Named Parameters in C# 3
Doubt in C-Sharp 1

Back
Top