using System;
class RefType
{
public void sqr(ref int i)
{
i = i * i;
}
}
class MainClass
{
public static void Main()
{
RefType ob = new RefType();
int x = 20;
Console.WriteLine("a before call: " + x);
ob.sqr(ref x);
Console.WriteLine("a after call: " + x);
}
}
------------------------
OUTPUT:-
a before call: 20
a after call: 400
----------------------------------------------------
class RefType
{
public void sqr(ref int i)
{
i = i * i;
}
}
class MainClass
{
public static void Main()
{
RefType ob = new RefType();
int x = 20;
Console.WriteLine("a before call: " + x);
ob.sqr(ref x);
Console.WriteLine("a after call: " + x);
}
}
------------------------
OUTPUT:-
a before call: 20
a after call: 400
----------------------------------------------------
No comments:
Post a Comment