Call by Reference And Call by value

Hi,Plz have luk @Below code:- plz explain me .....whether its call by Call by Reference OrCall 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


Reply

Gravatar
ketan3 years ago

its call by value. but the value which is passed to fun is override in function of class so the output C is a formal argument to fun, and value of B comes in C after that c is set to ABCD. So, B is actual argument n c Formal.. We can give any name to formal argument. -Thanks


Forum Post

Create a Custom 404 Page
  •  3 years ago
  •  Tushar
Website Optimization
  •  3 years ago
  •  Tushar
Call by Reference And Call by value
  •  3 years ago
  •  robertj
Execula is a platform for web development for a variety of complex and sophisticated enterprise level applications in several domains.
3145 E Chandler Blvd., Suite 110-743
Phoenix
Arizona
85048-8702
USA