What is the difference between obj.i
and reference int k
? They point to same address. Which one is better and why?
namespace ConsoleApplication1
{
class pro
{
public void met1(ref int k,Program obj)
{
obj.i = 30;
k = 20;
}
}
class Program
{
public int i=10;
static void Main(string[] args)
{
Program pi = new Program();
pro p = new pro();
p.met1(ref pi.i, pi);
Console.WriteLine(pi.i);
Console.ReadKey();
}
}
}