다음 문에서 StringComparison.CurrentCultureIgnoreCase를 사용하는 방법을 알아보십시오. 여기에 배열 요소가 문자열 dummyAccount에 있는지 여부를 확인합니다.다른 문자열의 배열 항목을 검사하는 동안 StringComparison.CurrentCultureIgnoreCase를 사용하는 방법
모든 것이 좋지만 StringComparison.CurrentCultureIgnoreCase 만 사용하려고합니다.
private string getAccount(string dummyAccount)
{
//e.g dummyAccount="resturant business";
string Account = string.Empty;
if ((new string[] { "abc", "Xyz","MD" }).Any(dummyAccount.Contains))
{
Account = "Unknown account";
}
else if ((new string[] { "shop", "hotel", "Resturant","Business"}).Any(dummyAccount.Contains))
{
Account = "Business";
}
else if ((new string[] { "school", "college" }).Any(dummyAccount.Contains))
{
Account = "University";
}
--------------------------------------------------------------
--------------------------------------------------------------
--------------------------------------------------------------
--------------------------------------------------------------
--------------------------------------------------------------
return dummyAccount;
}
예컨대
경우 dummyAccount = "음식점 사업";
Account = "Business";
당신은 속임수와 할 수있는 시도'dummyAccount.ToLower는() '(외부 변수를 만들) – Sayse
물론, 모든 배열 항목을 낮은 값으로 변환하고 싶지는 않습니다. –