2015-04-02 18 views
0

我有兩個字符串,我必須通過linq迭代?如何使用Linq比較同一列中的兩個字符串?

我有狀態作爲列和

 Status 
    -------- 
    Int 
    String 
    Boolean 
    Char 
    Float 

LINQ

var result = from desc in result 
where desc.Status == "string" && desc .Status == "Int" 
select desc ; 

其具有行價值如何實現這個..我已經試過,但它返回空。如果我嘗試單一檢查其正常工作。

回答

5

您需要使用||操作

where desc.Status == "string" || desc .Status == "Int" 
+0

我需要兩個字符串和int數據... – 2015-04-02 09:17:45

+0

@AravindanSrinivasan,在一個時間點,你只能有一個值。它可以是字符串或int。請詳細說明 – Satpal 2015-04-02 09:18:40

+1

謝謝..其工作:) – 2015-04-02 09:19:50

1
var result = from desc in result 
      where new[] {"Int","String","Boolean","Char","Float"}.Contains(desc.Status) 
         select desc ;