C#中是否沒有OR操作數用於字符串?或用於字符串的C#中的操作數
我正在看微軟的C#操作數頁面 - 並沒有任何關於字符串的OR。
我有一個if語句我想寫:
if (Convert.ToString(r["first_name"]) != "Antoine" || "Brad" || "Programming" || "Admin" || "Patricia")
{
其中C#是窒息與此錯誤:
CS0019: Operator '||' cannot be applied to operands of type 'bool' and 'string'
我用Python和PHP,其中做允許類似的東西。
什麼是適當的C#語法?
也許http://stackoverflow.com/questions/4987873/how-to-find-if-a-string-contains-any-items-of-an-list-of-strings將幫助 – quip
@AndrewAlexander運算符aren不是爲類型而是爲布爾表達式設計的。 –
@MatíasFidemraizer嗯,無論如何,布爾運算符都是如此。 – Servy