Suppose a class called "Location" stores locations and related data:
class Place
{
string Name;
string Location;
}
Later we fill out the name and details to 80 different cities. Therefore, we store these cities numerically in an array:
class Setup
{
public static GetTowns
{
for (int i = 1; i <= numberOfTowns; i++)
{
Town[i] = new Place(name, location);
}
}
}
To access a specific city and its data, we pass the city itself as a parameter and get it:
public static void DescribeTown(Place Town)
{
Console.WriteLine("Shipping to {0}.", Town.Name);
}
Other methods require access to several cities or all of them. Then we can pass the entire Town array as a parameter:
public static void ListAllTowns(Place[] Town)
{
Console.WriteLine("Our Beloved Clients:");
foreach (Place here in Town)
{
Console.WriteLine("{0} in {1}", here.Name, here.Location);
}
}
The full C # 2.0 reference states the following
Parameters are variables that receive the value of the arguments passed to the method when it is called.
, ListAllTowns , . , ?
( , .)