کاربر مبتدی
شنبه 07 بهمن 1391, 11:47 صبح
من در دروس کتاب آقای هاشمیان سعی کردم تمام دروس را با wpf بروم ولی در درس سوئیچ خروجی درستی نگرفتم (در wpf) لطفاً راهنمایی کنید.
private void lstData_SelectedIndexChanged(object sender,
EventArgs e)
{
// Declare variables
string strName;
string strFavoriteColor = "";
// Get the selected name
strName =
lstData.Items[lstData.SelectedIndex].ToString();
// Use a Switch to get the favorite color
// of the selected name
١٣٠
switch(strName)
{
case "Bryan":
strFavoriteColor = "Madras Yellow";
break;
case "Stephanie":
strFavoriteColor = "Sea Blue";
break;
case "Cathy":
strFavoriteColor = "Morning Mist";
break;
case "Betty":
strFavoriteColor = "Passionate Purple";
break;
case "Edward":
strFavoriteColor = "Battleship Gray";
break;
}
// Display the favorite color of the selected name
MessageBox.Show(strName + "‘s favorite color is " +
strFavoriteColor, "Select Demo");
}
private void lstData_SelectedIndexChanged(object sender,
EventArgs e)
{
// Declare variables
string strName;
string strFavoriteColor = "";
// Get the selected name
strName =
lstData.Items[lstData.SelectedIndex].ToString();
// Use a Switch to get the favorite color
// of the selected name
١٣٠
switch(strName)
{
case "Bryan":
strFavoriteColor = "Madras Yellow";
break;
case "Stephanie":
strFavoriteColor = "Sea Blue";
break;
case "Cathy":
strFavoriteColor = "Morning Mist";
break;
case "Betty":
strFavoriteColor = "Passionate Purple";
break;
case "Edward":
strFavoriteColor = "Battleship Gray";
break;
}
// Display the favorite color of the selected name
MessageBox.Show(strName + "‘s favorite color is " +
strFavoriteColor, "Select Demo");
}