Method local variable
In this chapter you will learn:
Local variable initial value
C# requires that local variable must have assigned value.
using System;/*j av a 2 s.c om*/
class Program
{
static void Main(string[] args)
{
int i;
Console.WriteLine(i);
}
}
Compile the code above:
To fix the problem, assign a value to the local variable i.
using System;/* j av a2s. c o m*/
class Program
{
static void Main(string[] args)
{
int i = 5;
Console.WriteLine(i);
}
}
We don't need to initialize each elements in an array explicitly, since array elements are initialized by C#.
Next chapter...
What you will learn in the next chapter:
Home » C# Tutorial » Class