Hi all i am a absolute beginner of c#5.0 and i want to understand how the Console.Writeline is different for optional parameters e.g
class test
{
static void Prg(int a=0,int b=0,int c=0,int d=0)
{Console.Writeline(a,b,c,d);}
static void Main()
{
Prg();
}
i want to print values for a,b,c,d as 0 0 0 0 in o/p
but iit shows error as 'overload method has some invalid arguments.
tell me methods for Console.Write() for this code,thanks in advance.
Loading

Khan Abrar AhmedPosted Jun 8, 2014, 2:25 AM
Console.WriteLine("{0}, {1}, {2},{3}",a,b,c,d);VulpesPosted Jun 8, 2014, 12:01 PM
Hemant SharmaPosted Jun 8, 2014, 2:12 AM
Khan Abrar AhmedPosted Jun 8, 2014, 2:07 AM
0
0
0
0
Hemant SharmaPosted Jun 8, 2014, 2:03 AM
Khan Abrar AhmedPosted Jun 8, 2014, 1:51 AM
class test
{
static void Prg(int a=0,int b=0,int c=0,int d=0)
{
Console.Writeline(a.tostring());
Console.Writeline(b.tostring());
Console.Writeline(c.tostring());
Console.Writeline(d.tostring());}
static void Main()
{
Prg();
}
or
Console.WriteLine("{0}, {1}, {2},{3}", // <-- This is called a format string. a, // <-- These are substitutions. b, c,d);