Wednesday, October 22, 2014

call by value and call by reference in c#.net

Posted by Unknown  |  No comments


 if you want more related search please click here  
 please help to other  
 http://scriptquery.blogspot.in/  
 call by value and call by reference in c#.net  
 using System;  
 namespace callbyvalue  
 {  
   class Program  
   {  
     public class employee  
     {  
       public void display(int a, String b)  
       {   
         Console.WriteLine("Integer value is"+" " +a);  
         Console.WriteLine(" String value is" + " " + b);  
         Console.ReadLine();  
       }  
     }  
     public class student  
     {  
       public void show(ref String str)  
       {  
         Console.WriteLine("Enter the value");  
         string s = Console.ReadLine();  
         str = str + s;  
         Console.WriteLine("value in str variable is"+" "+str);  
         Console.ReadLine();  
       }  
     }  
     //all class member is called through main method.  
     static void Main(string[] args)  
     {  
       //creating the object of employee class first and implementing the call by value concept.  
       String m = "sunil";  
       employee emp = new employee();  
       emp.display(200,m);  
       Console.WriteLine("value in variable m is" +" "+m);  
       Console.ReadLine();  
      //creating the object of employee class first and implementing the call by Reference concept  
       string msg="Hello";  
       student st = new student();  
       st.show(ref msg);  
       Console.WriteLine("value in msg is" +" "+msg);//value at address msg will be print,because here address is copy not value thatswhy at same address value will be print  
       Console.ReadLine();  
     }  
   }  
 }  
 if you want more related search please click here  
 please help to other  
 http://scriptquery.blogspot.in/  

4:07 AM Share:

0 comments:

Get updates in your email box
Complete the form below, and we'll send you the best coupons.

Deliver via FeedBurner
Proudly Powered by Blogger.
back to top