Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
what is te meaning of the ref in nd Out with some practical explanation ? and an example
Posted
Comments
ZurdoDev 20-Aug-12 10:51am    
What language?

ref- use to pass by reference in function argument
out-similar to ref but pass out value from the function..below example

C#
class Test
{
	void refDemo(ref int i)
	 {
		i= i*10;
	 }
        int FindDecimal(float f,out float dp)
	 {
		int i=(int) f;
                dp=f-i;
                return i;
	 }
}

class RefExample
{
  public statc void Main(string []args)
   {
	Test obj=new Test();
        int i=10;
	Console.WriteLine("Before Call i:" + i);
	obj.refDemo(ref i);
	Console.WriteLine("After Call i:" + i);
	obj.FindDecimal(12.2345f,out float f);
	Console.WriteLine("Decimal points f:" + f);
   }
}
 
Share this answer
 
v2
I suggest you read a little bit C# because this question would mean you need some basics covered before jumping to implementation.

Here is a very good crash course link. this will also answer your question and cover other basic details too.

Quick C#[^]
 
Share this answer
 
Comments
Manas Bhardwaj 21-Aug-12 9:15am    
Well said +5
Don't flood the boards. Buy a book. This is basic stuff, and has NOTHING to do with ASp.NET, nor can we give an example in the language you're using if you don't tell us, but either way, you're asking us to do stuff you can do for yourself. Type your questions in to google. Buy a book. Don't expect us to do it all for you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900