using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class program { public static void Main(string[] args) { string S3 = "Male"; int number = 1101; string S1 = "John"; string S2 = "Mayer"; int i = 0; int j = 1; int k = 2; Trial tobj = new Trial(); /* Here the second and third arguments are strings. */ tobj.setval(number, S3, String.Concat(S1, S2)); tobj.sample(1, z: 3, y: 2); tobj.sample2(j + 3, j, j + 5); tobj.sample3(++i, ++i, ++i); tobj.sample4(j: ++k, g: ++k, h: ++k); A a = new A(); B b = new B(); C c = new C(); a.F("hello"); b.F(1); c.F(1); } } class A { public void F(String s) { Console.WriteLine("F's value"); } } class B { public void F(int i) { Console.WriteLine(i); } } class C { public void F(int w) { Console.WriteLine("W's value"); } } class Trial { /* The second value passed is "male". The value of third arg is "John Mayer". But since the * second parameter is name in function definition, the value "male" is passed to it. This shows that the ordering is from left to right when the data type of the parameters are same*/ public void setval(int empID, string eName, string eGender) { System.Console.Write(" Employee Name:"); System.Console.WriteLine(eName); System.Console.Write("Employee Number:"); System.Console.WriteLine(empID); System.Console.Write("Gender:"); System.Console.WriteLine(eGender); } /* Here all 3 parameters are integers. But in method declaration, it is specified that z is 3 * and y is 2. So those appropriate values are passed to the parameters in function definition*/ public void sample(int x, int y, int z) { Console.Write("Value of z:"); Console.WriteLine(z); Console.Write("Value of y:"); Console.WriteLine(y); } /*Here j is declared as 1. But the first parameter has the value j+2 =3, second parameter has * just the same value of j and third has j+5 =6. The same values are passed in the same order from left to right. But the inceremented value of first parameter does not affect the value of second parameter*/ public void sample2(int a, int b, int c) { Console.Write("Value of a:"); Console.WriteLine(a); Console.Write("Value of b:"); Console.WriteLine(b); Console.Write("Value of c:"); Console.WriteLine(c); } /*Here i is declared as 0 and the inceremented values are passed in order left to right to i * respectively. This shows that parameter ordering is from left to right. */ public void sample3(int k, int l, int m) { Console.Write("Value of k:"); Console.WriteLine(k); Console.Write("Value of l:"); Console.WriteLine(l); Console.Write("Value of m:"); Console.WriteLine(m); } /*Here k is declared as 0 and the inceremented values are passed in order left to right to k, *to j,g,h respectively. * This shows that parameter ordering changes if the name of parameter is specified */ public void sample4(int g, int h, int j) { Console.Write("Value of g:"); Console.WriteLine(g); Console.Write("Value of h:"); Console.WriteLine(h); Console.Write("Value of j:"); Console.WriteLine(j); } } }