Wednesday, 7 August 2013

C# variables, methods, reference exercise

C# variables, methods, reference exercise

I have made an exercise on C#, here it is:
class Program
{
static double funk(int a, ref int b)
{
double c = a + b;
a = 5;
b = a * 3;
return c;
}
static void Main(string[] args)
{
int a = 1, b = 2;
Console.WriteLine(funk(a, ref b));
Console.WriteLine(a);
Console.WriteLine(b);
Console.ReadLine();
}
So, the result is pretty clear when I run the code, it gives me:
3 1 15
My question now is, where did 15 and 3 came from?

No comments:

Post a Comment