There are two types of parameters are there in c#
1.Ref parameter
paramerer should be intilized before passing as ref parameter
EX:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Parameteres
{
class Program
{
static void Main(string[] args)
{
int i=0;
Program obj = new Program();
obj.show(ref i);
Console.WriteLine(i);
Console.ReadKey();
}
public void show(ref int i)
{
i = 10;
}
}
}
2.out paramete we no need to initilize the values, and both the methods we can retrun multiple values
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Parameteres
{
class Program
{
static void Main(string[] args)
{
int i, j ;
Program obj = new Program();
obj.show(out i, out j);
Console.WriteLine(i);
Console.WriteLine(j);
Console.ReadKey();
}
public void show(out int i,out int j)
{
i = 10;
j = 20;
}
}
}
Wednesday, April 3, 2013
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment