???? ????
??????? ???? ????? ???????? ? ????? ?????? ??? ??? ???
??? ???? ? ?????? ?? ???? ??? ???? ???? ???? ?? ???? ??? ??? ?? ???? ???????? (????? ?????? ????? ????????) ?? ?????? ??? ????? ??????? ??????. ?? ??? ????? ??? ??? ?????? ?? ?????? ?????? ?? ?????? ???? ...
Download Firefox
Download Safari
Chrome browser download link is disabled!
Download Flock
Download Opera
???? ??? ?? ????? ????
????? ??????
ما 16 مهمان آنلاین داریم
???? ?????? ?? ????

?????? ????? ?????:5
????? ??????? ?????:12
?????? ????? ?????:4
?????? ????? ??? ???:106
?????? ????? ??:33868
????? ??????? ??:159009
??????? ?????? ???:1383
Date since:2009-03-05
???? ?? ????

postheadericon ??? ???? ?????? ???? ?? #C

??? ?????? ???? ????? ??? ??? ?? ????? ?? ?? ?? ????? ?? ???? ????

?????

?? ??? ??? ?????  ?? ??? ?????? ??? ?????? ?? ? ?????? ??  ?? ???????? ?? ???   main ???? ?? ????  ?? ???? ?? ??? ???? ?????? ??? ???? ?? ???? ??????? ????? ??? ?????  ??????? ?? ????? ???? ???. ??? ????? ???? ????????? ?????? ?? ?? ??????? ?? ????? ???? ????.

??? ?? ??? ??? ??????? ????????  ?? ???? ????? ????  ?? ??? ????? ?? ????? ?? ???? ??? ????

????? ??? ??? ?? ??? ??? ??? :

v    ??? ?????? ????? .

v    ?????? ????? ??? ??? ?????? static ? instance

v    ??????? ????? ????? ???? ?? ?????

v    ??? ????? ????? ????????  ?????? ?? ?? ????? ???? ???

v    ??? 4 ??? ???????

v    ??????? ????? ??????? ???? ?????? this

?????? Method ??

??? ?? ???? ???? ????? ????? ?? ??? ????? ?? ???? ????? ?? ?? ?????? ?????? ? ???? ????? ????. ??? ?? ?????? ?????????? ?? ?? ????? ?? ?? ??? ????? ? ??????? ????? ?????? ?? ??? ??  ????? ????.

?????? ????? ????????? ? ?????? ??????? ??????? ???. ? ?? ???? ?? ?? ?????? ??? ????? ??? ????? ????. ?? ????? ???? ??? ????? ???? ???:

attributes modifiers return-type method-name(parameters)

    {

        statements

    }

Attribute ?? ? modifier ?? ?? ??? ??? ??? ????? ????? ???.  return-type ?? ???? ??? ????? ??? ?? ???? ?? ??? ? ?? ????? ?? ???? ?? ????? ????? ??? C# ????. ??????? ?? ??? ????? ??? (void) ????? ?? ???? ?? ?? ?? ?? ????? ???? ??????? ?? ????? ?????? ???. method-name ????? ?? ????? ?? ??? ??? ?? ??? ?? ?????? ?? ?? ??? ?? ???????? ????. ??? ??? ???? ???? ???? ????? ?? ?????? ???? ?? ??? ????????? ?? ?????? ???? ???  . ????????? (parameters) ?? ??? ????? ?? ???? ?? ?????????? ?? ?? ??? ????? ?? ?? ?? ?????? ????. ???? ???? ???????? ???? ???????. ??????? ???? ?????? ??????? ?? ?? ???? ???? ??? ????? ???? ?? ???? ?? ????. ???? 5-1. ????? ?? ?? ??? ???? ???.

?????? 1-5 ?? ??? ????

using System;

class OneMethod
{
public static void Main()
{
string myChoice;

OneMethod om = new OneMethod();

do
{
myChoice = om.getChoice();

// Make a decision based on the user's choice
switch(myChoice)
{
case "A":
case "a":
Console.WriteLine("You wish to add an address.");
break;
case "D":
case "d":
Console.WriteLine("You wish to delete an address.");
break;
case "M":
case "m":
Console.WriteLine("You wish to modify an address.");
break;
case "V":
case "v":
Console.WriteLine("You wish to view the address list.");
break;
case "Q":
case "q":
Console.WriteLine("Bye.");
break;
default:
Console.WriteLine("{0} is not a valid choice", myChoice);
break;
}

// Pause to allow the user to see the results
Console.WriteLine();
Console.Write("press Enter key to continue...");

Console.ReadLine();
Console.WriteLine();

} while (myChoice != "Q" && myChoice != "q"); // Keep going until the user wants to quit
}

string getChoice()
{
string myChoice;

// Print A Menu
Console.WriteLine("My Address Book\n");

Console.WriteLine("A - Add New Address");
Console.WriteLine("D - Delete Address");
Console.WriteLine("M - Modify Address");
Console.WriteLine("V - View Addresses");
Console.WriteLine("Q - Quit\n");

Console.Write("Choice (A,D,M,V,or Q): ");

// Retrieve the user's choice
myChoice = Console.ReadLine();
Console.WriteLine();

return myChoice; 
}
}

?????? ????? ??? ?? ????5-1  ????? ???? do  ?? ??? 4 ??? ??????? ????? ???? ??? ??? ? ????? ????? ?? ??? ??? ???? ??? ?????? ?? ??? ????? ?? ??? getChoice() ???? ?? ????. ??? ??????? ?? ??? ???? (String) ???. ?? ??? ???? ?? ????? switch ?? ??? Main()  ??????? ??? ???. ????????? ???? ?? ???? ?? ??? ??????? ??? ???? ???? ??? ?? ??????? ?? ??? ????? ??? ???. ???? ???? ??? ?? ??????? ?????? myChoice ??  ????? ?? ????. ?????  ??? ? ??? ??? ????? ??  ??? ????? myChoice ????? ?? ??? Main()  ???? ??? ?????? ?????? ??????? ?? ?????. ?????? ???? ???????? ???? ????? ? ???? ?? ????? ?? ????? ???? ?????? ?? ???? ? ???? ?????? ?????. ?? ???? ???? ?? ????? myChoice ?? ???? getChoice() ????? ???? ??? getChoice() ?? ???? myChoice ????? ???? . ??? getChoice() ????? ?? ?? ????? ??? ?? ???  ? ????? ??? ????? ?? ?????? ?? ???. ????? return ??????? ?? ?? ???? ????? myChoice ?? ??? ?????????? ??? ???? Main()  ?? ??????. ???? ???? ?? ???  ?????? ?? ?? ????? ??????? return ????????? ?? ???  ???? ???? ??? ?????? ?? ???? ????? ??????  ????. ????? ???? ??? ??????? ?? ???? ???. ?? ??? Main()  ??? ?? ??????? ?? getChoice() ???? ?? ????? ???? ?? OneMethod ??????. ?? ?????? ?? ??  ??  static modifier ?? ????? ??? ????  Main()  ? getChoice()  ??? ????? ?? ?? ????. ?????? ?? ?????? ????? ?? ?? ?????? ????? ????? ?? ??? ?? ????? ?????  ????? ????? ????? ?? ???? ?? ???? ????? ???  ???????? ??? getChoice() ??????? ??? ?? ????. ???? ?? ??????? ??? ???? ??? ????? ?? ????? ????? ????? ???? ????? ???. ???????? ??? getChoice()  ????? ???? ?? ???? ???? ??????? ?? ?? ??? ?????  ????? ???. ????? ??? ???? ?????? myChoice = om.getChoice(); ???? ????????. ?? ??? ?? ??? ????? ???? ??? ??? ?????( ???? om)? ???? ???? ?? ?? ??? OneMethod ???. ?????? ?? ?? ???? om ??????? ???? ???? ??? ???. om ?? ???? ??? ??? ???? ???? ???????? ?? ??????? ????? ?? ????? ?? ???  OneMethod ?? ?? ??? ????????. ?? ??? ???? ??? ????? ?? ????? ?? ??? OneMethod ??  ???? om ????? ???? ??? ??? . ???? ????? new  ?? ????? C# ??? ?? ??? ????? ?? ?? heap ????? ?? ???. ???? ?? ????? ?? ???? ???? ?? ?? ????? ????? ?? OneMethod ?? heap ????? ??? ? ??? ?? ???? om ????? ???? ??????. ??? ?? ???????? ?? ???? OneMethod ?? om ????  ????? ???????  ?? ?? ?????? ?? ???? ???? om ?? ?? ???????. ?????? ?????? ? ???? ??? ??? ?? ???? ?? ???? ????? ???? "." ?? ??????  ???????? ??????? ?? ??????? ????. ???????? ????????? ??? getChoice() ?? ??? ????? ? ?? ???? ????? ???? ?? ???? om ?? ?? ?????? ???? ????????? : om.getChoice()

?????? ??????? ?? ?? ??????? ?? ????  getChoice() ???? ????? ? ?????????? ???? ??????? ?????? ?? getChoice() ?? ?????????? ?? ????? "=" ???????  ???? ???. ???? ??????? ?? ??? getChoice() ???? ????? ???? myChoice ??? Main()  ???? ???????.

?????? 2- 5 ??????? ?????

using System;

class Address
{
public string name;
public string address;
}

class MethodParams
{
public static void Main()
{
string myChoice;

MethodParams mp = new MethodParams();

do
{
// show menu and get input from user
myChoice = mp.getChoice();

// Make a decision based on the user's choice
mp.makeDecision(myChoice);

// Pause to allow the user to see the results
Console.Write("press Enter key to continue...");
Console.ReadLine();
Console.WriteLine();
} while (myChoice != "Q" && myChoice != "q"); // Keep going until the user wants to quit
}

// show menu and get user's choice
string getChoice()
{
string myChoice;

// Print A Menu
Console.WriteLine("My Address Book\n");

Console.WriteLine("A - Add New Address");
Console.WriteLine("D - Delete Address");
Console.WriteLine("M - Modify Address");
Console.WriteLine("V - View Addresses");
Console.WriteLine("Q - Quit\n");

Console.WriteLine("Choice (A,D,M,V,or Q): ");

// Retrieve the user's choice
myChoice = Console.ReadLine();

return myChoice; 
}

// make decision
void makeDecision(string myChoice)
{
Address addr = new Address();

switch(myChoice)
{
case "A":
case "a":
addr.name = "Joe";
addr.address = "C# Station";
this.addAddress(ref addr);
break;
case "D":
case "d":
addr.name = "Robert";
this.deleteAddress(addr.name);
break;
case "M":
case "m":
addr.name = "Matt";
this.modifyAddress(out addr);
Console.WriteLine("Name is now {0}.", addr.name);
break;
case "V":
case "v":
this.viewAddresses("Cheryl", "Joe", "Matt", "Robert");
break;
case "Q":
case "q":
Console.WriteLine("Bye.");
break;
default:
Console.WriteLine("{0} is not a valid choice", myChoice);
break;
}
}

// insert an address
void addAddress(ref Address addr)
{
Console.WriteLine("Name: {0}, Address: {1} added.", addr.name, addr.address); 
}

// remove an address
void deleteAddress(string name)
{
Console.WriteLine("You wish to delete {0}'s address.", name); 
}

// change an address
void modifyAddress(out Address addr)
{
//Console.WriteLine("Name: {0}.", addr.name); // causes error!
addr = new Address();
addr.name = "Joe";
addr.address = "C# Station";
}

// show addresses
void viewAddresses(params string[] names)
{
foreach (string name in names)
{
Console.WriteLine("Name: {0}", name);
}
}
}

???? 2-5 ??? ????? ????? ???? 1-5 ??? ?? ???? ?????? ??????? ??? ?? ????? ????? ????????? ?? ???? ?? ???. ?? C# ???? ???? ??????? ???? ????   ref?  out? params ? value .?? ??? ?? ????? ????? ??????? ?? ????????? ????? ?? ??? Address ?? ?? ???? ?? ??? ???? ????? ???? ??? . ??  Main ? getChoice() ?? ???????? ??????  ?? ????? ?????  ?? ?????? ???? ? ??? ???? ?? ????? ??????? myChoice ???? ??????? .  ??? ????? myChoice ?? ?????? ??????? ?? ??? makeDecision()  ??????? ??????. ?? ????? myDecision()? ??????? ?? ?????? ?? ???? ? ??????? ??? ??? ?? ??? ???? ? ?? ??? myChoice ????? ??? ???. ???????? ?? myChoice  ??????? ?? ??????? ???????? ??? ??  ???? ??? ????? ???? ??? ??? ???? ??????? ???. ????? ?? ?????  ???? ???? ?????????? ?? ??? modifier ????? ????? ??? ??????? ?????? value ???? ??????? ?????? . ?????  ?????? ????? ?? ??????? ?? ???? (Stack) ??? ??????. ????????? ?? ?? ????? ?????? ?????? ??????? ???? ?? ??? ????? ????????????????? ???? ???? ? ??????? ????? ??? ?? ??? ???? ?????? ?? ??? ????? ???? ????? ??? ??? .

????? switch ?? ??? makeDecision() ???? ?? case ?? ??? ?? ??? ?? ???. ???????? ??? ????? ?? ???? ?? ??? Main()??????? ?? ?????? ?????? ???. ???? ??????? ?? ???? mp ????? ???????? ?? ?????? ????? this ?? ??????? ??? ???. ???? ????? this ?????? ?? ?? ?? ???? ? ????? ??????. ?? ?? ??? ???? ?? ?? ????? ???? ??? ??? ???????? ????? makeDecision ?? ??? ????? ????. ???????? ?? ???????? ?? ???????? ?????? ???? ???? ????? ?????? ????. ??? addAddress ???????? ?? ??? ref ??????. ?? ??? ???? ?? ????? ?? ??? ??????? ?? ??? ??? ?????. ??? ???? ?????? ?? ???? ?? ?? heap ????? ???? ?? ???? ??????? ?? ????? ????? ???? ?? ??????? ???????? ??? ??? . ??? ???? ???? ??? ?? ?? ?????? ????? ?????? ???? ????? ??? ???? ????? ????? ?????? ???? ?? ????? ?????. ???? ????? ?????? ??? ??????? ?? ?? ?? ?? ?? ?????? ??? ????? ???. ??? ?? ?????? ?? ?? ?? ?? ????? ?????????? ????? ? ????? ?? ??? ??????. ??? ?? ????? ?? ????? ???????? ??????? ????? ??? ???? ????? ??? ????????? ?? ????? ?? ?? ????? ?? ??? ??? ???????. ?? ??????? out ?? ????? ????? ????? ?? ????? ????? ??? ?? ??   ??? ???? ????? ?????  ????? ?? ??????? out ??? ??????. ?????????? out ??? ?? ????  ?????????? ?? ?????? ???? ???????. ??? ?? ?????? ??????? ?? ?????? ????? ????? ????? ??? ??? ?????? ??????? ????. ????? ?? modifyAddress() ???????? ?? ????? ???? ???? ???? this ??? . ?? ???? ??? ?? ??????? ? ??????? ???? ?????? ???? ?? ?? ????? ?? ???? ?????? ??? . ????? ???? ?????? ???? ???? ????? ??????? out ??? ????? ?? ???? ???????? ?? ??????? ?????? ?? ???  . ????? ???? ?? ?? ??????? out  ????? ???? ??? ?? ????? ?????? ?????????? ???. ??? ?? ????? ??? ???? ?? ????  c# ??????? params  ??? ?? ?? ??? ????? ?? ??? ???? ?? ????? ???? ?? ?????? ?????? ?? ?? ????? ??????? ?? ?????. ?????????? params ???? ??? ?? ????? ????? ?? ???? ? ?? ????? Jagged ????. ???? viewAddresses() ?? ???????? ??????  ??????? ??  ?? 4 ????  ????? ?? ????  . ?????? ??????? ?? ???????? ? ?? ??? ?????? ?? ???? ????? ?? ????. ?? viewAddresses() ?? ?? ??????? ?? ???? foreach ?????? ?? ??? ???? ?? ?? ??? ?? ????. ???? ????? ?? ??????? ??? ???? ?? ????? ?? ?? ????? ????? ?? ?? ?? ???? ????.

?????????? params ??? ???????? ????? ?????? ????????? ? ???????? ?? ?? ??? ???? ??? ??? ?? ??? ????? ???? ????? ????????.

?????

??? ????? ??? ?????? ?? ??? ?? ???????? . ???  4 ??? ???????c #   params  value, ref, out ???? ????. ???? ?? ??? ????? ?? ??? ????? ??????? ???? ???? ?? ?? ????? ?????? ?? ???? ?? ?? ?? ??????  static ????? ????  ???????? ?? ?????? ?? ?? ???????? ????.