Hey
The code below generates this compile error:
Use of unassigned out parameter 'x'
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
public static void A(out int x)
{
Console.WriteLine(x);
x = 1;
}
public static int Main(string[] args)
{
int y = 3;
A(out y);
return 0;
}
}
}
I don't understand why I get that error. In Main I give y the value 3, then
I send y into A... y becomes x in A so it should work.... but no don't
work.. I get this compile error mention above....
Is it so that a parameter sent (using out) into a method always must be
given a value before it can be used in the method? That sounds very unlikely
to me.. but then again I'm just trying to learn C# :-)
I would appreciate if some of you could give a comment on why I get that
compile error!
Jeff