我們如何切換以下,如果-else報表切換case語句..任何人都可以幫助這個...開關elseif的切換情況下
if (Webcc1.Contains(licensePartID))
{
dtExpiryDate = dtActivatedDate.AddYears(1);
int isExpiry = DateTime.Compare(dtActivatedDate, dtExpiryDate);
if (isExpiry >= 0)
{
setError(lblSystemErr, "This action cannot be performed. The subscription period of the license key has expired");
return;
}
}
else if (Webcc3.Contains(licensePartID))
{
dtExpiryDate = dtActivatedDate.AddYears(3);
int isExpiry = DateTime.Compare(dtActivatedDate, dtExpiryDate);
if (isExpiry >= 0)
{
setError(lblSystemErr, "This action cannot be performed. The subscription period of the license key has expired");
return;
}
}
else if (Webcc5.Contains(licensePartID))
{
dtExpiryDate = dtActivatedDate.AddYears(5);
int isExpiry = DateTime.Compare(dtActivatedDate, dtExpiryDate);
if (isExpiry >= 0)
{
setError(lblSystemErr, "This action cannot be performed. The subscription period of the license key has expired");
return;
}
}
提前許多感謝....
你不能。 Switch語句不能像那樣工作。如果它是'Webcc3 == licensePartID',你就有機會 – Rob
有你的解決方案http://stackoverflow.com/questions/21255198/is-there-a-way-to-integrate-a-switch-with -string-包含 – elhampour
@Rob:不可能只需要一段時間;-) –