15
If the variable i is an instance variable, it will be assigned the value 0 automatically. If it is a local variable in a method, it is undefined, so you would need to assign it a value before using it.
For example:
class Program
{
static void Main(string[] args)
{
intTest it;
it = new intTest();
Console.ReadLine();
}
class intTest
{
int i;
public intTest()
{
int i2;
Console.WriteLine("i = " + i);
Console.WriteLine("i2 = " + i2);
}
}
}
The above will not compile because i2 is unassigned. However, by assigning 0 to i2, i.e.
int i2 = 0;
and compiling, then running, will show that both are now assigned 0.