Aman Jen

Aman Jen

  • NA
  • 137
  • 31.5k

Call by Reference And Call by value

Oct 1 2013 6:02 AM
Hi,Plz have luk @Below code:- plz explain me .....whether its call by Call by Reference Or Call by value 






    class Program
    {
        public static void Input(string C)
        {
           C= "ABCD";
            Console.WriteLine(C);
        }
        static void Main(string[] args)
        {
            string B = "EFGH";
             Program.Input(B);
             Console.ReadKey();
        }
    }

Output : ABCD

1)Looking at the example it shows its call by value becoz , if we use call by refrence then we have to use ref keyword which is not in this case so its call by value according me.


2)But then,  if it is call by value it should print "EFGH", but rather its printing "ABCD" of input method .




Why plz explain..




Thnx in Advance






Answers (4)