payday loans
codecandle logo




 

C# - Functions - Variable Scope


Related: C# Tutorial

Date: 30.04.2011

Variable in C# have a scope within which they are valid. Scope indicates code block-nested code blocks that variable is defined.


namespace NS1
{
class Program
{

static void show()
{
Console.WriteLine(stateName); //ERROR: inaccessable here
}

static void Main(string [] args)
{
string stateName = "nebraska";
show();
Console.WriteLine(stateName); //OK

{
string stateName_2 = "nevada";
Console.WriteLine(stateName_2); //OK
}
Console.WriteLine(stateName_2); //ERROR: inaccessable here
}
}
}
<style>.aks4{position:absolute;clip:rect(437px,auto,auto,412px);}<<span class="quoted">//style><div class<span style="color:gray;">=</span>aks4><a href<span style="color:gray;">=</span>http:zozpaydayloans.com >payday loans<</span>a><div></span> </p> <b>Area:</b> articles<br> <br> <b>Reference resources: </b><a href='http://msdn.microsoft.com/en-us/library/aa200276%28v=office.11%29.aspx
  • comment icon
  • Comments Section

Chat section


[ Copy this | Start New | Full Size ]