Scope van variabelen
if( iLoveCSharp == true)
{
Console.WriteLine("Hoeveel punten op 10 geef je C#?"):
int getal ; //Start scope getal
getal = int.Parse(Console.ReadLine());
} // einde scope getal
Console.WriteLine(getal); // FOUT! getal niet in deze scope{
int getal = 0 ; //Start scope getal
if( iLoveCSharp == true)
{
Console.WriteLine("Hoeveel punten op 10 geef je C#?"):
getal = int.Parse(Console.ReadLine());
}
Console.WriteLine(getal);
} // einde scope getalVariabelen met zelfde naam
Last updated
Was this helpful?