روﺷﻲ دﻳﮕﺮ ﺑﺮای ﻣﻘﺪار دھﻲ اوﻟﯿﻪ‬
strData[۰] = "۱۲۳۴";
strData[۱] = "abcd";


‫ ﺑﮕﺬارﻳﺪ. در اﻳﻦ ﻣﺜﺎل ﻣﻲ ﺧﻮاھﯿﻢ‬ex۰۶ ‫ ﺳﻲ ﺷﺎرپ را ﺑﺎز ﻛﻨﯿﺪ و ﻧﺎم آﻧﺮا در اﺑﺘﺪا‬Console ‫ﻣﺜﺎل : ﻳﻚ ﭘﺮوژه ی ﺟﺪﻳﺪ‬
: ‫ﻧﺤﻮه ی ﻛﺎر ﺑﺎ آراﻳﻪ ھﺎ را ﻣﺮور ﻛﻨﯿﻢ‬


using System;

namespace ex۰۶
{
class Class۱
{
[STAThread]
static void Main(string[] args)
{
string[] sGoalList = new string[۳];
string sReplyStatement = "You have choosen Goal '";

// Store goals in the array
sGoalList[۰] = "Hike the Appalachian Trail";
sGoalList[۱] = "Run the marathon";
sGoalList[۲] = "Give $۱ million to worthwhile causes";

// Store response to goals in the array
//(declaring and initializing on same line)
string[] sGoalResponse = {
"If you are staring from GA, you should get "
+ "started in early spring, so you will "+
"not get caught in snow.",
"Make sure that you have a good pair of shoes.",
"Start saving as soon as possible."};

// Give the user a list of goals to choose from
Console.WriteLine("GOAL LIST");

for(int i = ۰; i < sGoalList.Length; i++)
{
Console.WriteLine("Goal " + i +
" - " + sGoalList[i]);
}

‫.‪// Request the user to choose a goal‬‬
‫‪Console.WriteLine (""); // Write an empty line for space‬‬
‫" ‪Console.Write("Please choose the number of the‬‬
‫;(" :[۲,۱,۰] ‪+ "goal that you want to achieve‬‬

‫;()‪Console.ReadLine‬‬

‫{
‫{‬
‫{‬


‫ﻧﻜﺎﺗﻲ در ﻣﻮرد ﻛﺪ ﻓﻮق :‬
‫١- ﻧﺤﻮه ی اﺳﺘﻔﺎده از ﻋﻤﻠﮕﺮ + را ﺑﺮای اﺗﺼﺎل رﺷﺘﻪ ھﺎی ﺑﻠﻨﺪ در ﻛﺪ ﻓﻮق ﻣﻲ ﺗﻮان دﻳﺪ.‬
‫٢- در ﺳﻲ ﺷﺎرپ ﭘﺎﻳﺎن ﺧﻂ ﺳﻤﻲ ﻛﻮﻟﻮن ﻣﻲ ﺑﺎﺷﺪ. ﺑﻨﺎﺑﺮاﻳﻦ ﻧﮕﺮاﻧﻲ در ﻣﻮرد ﭼﻨـﺪ ﺧﻄـﻲ ﺷـﺪن ﻳـﻚ دﺳـﺘﻮر‬ ‫وﺟﻮد ﻧﺪارد.‬
‫٣- ھﻨﮕﺎﻣﻲ ﻛﻪ آراﻳﻪ ای را ﺑﺎ ﻣﻘﺎدﻳﺮ درون آﻛﻮﻻدھﺎ ، ﻣﻘﺪار دھﻲ اوﻟﯿﻪ ﻣﻲ ﻛﻨﯿﺪ ﻟﺰوﻣﻲ ﻧﺪارد ﻃﻮل آن آراﻳـﻪ را‬ ‫ﻣﺸﺨﺺ ﻛﻨﯿﺪ ؛ ﻣﺎﻧﻨﺪ آراﻳﻪ ‪ sGoalResponse‬ در ﺑـﺎﻻ. در ﻏﯿـﺮ اﻳﻨـﺼﻮرت ﺣﺘﻤـﺎ ﺑﺎﻳـﺪ ﻃـﻮل ﻳـﻚ آراﻳـﻪ را ﻛـﻪ‬
‫ﻣﻌﺮف ﺗﻌﺪاد ﺧﺎﻧﻪ ھﺎی ﺧﺎﻟﻲ آن اﺳﺖ ، ﻣﻌﺮﻓﻲ ﻛﻨﯿﺪ ﻣﺎﻧﻨﺪ آراﻳﻪ ‪. sGoalList‬‬
۴- ﻓﻌﻼ ﺣﻠﻘﻪ ی ‪ for‬را در اﻳﻦ ﻣﺜﺎل ﺑﺨﺎﻃﺮ داﺷﺘﻪ ﺑﺎﺷﯿﺪ ﺗﺎ در ﻣﻘﺎﻟﻪ ی ﺑﻌﺪی راﺟﻊ ﺑﻪ آن ﺻﺤﺒﺖ ﻛﻨﯿﻢ.‬