How to use not equal in linq

Hi Team,

I want to get the salary having value greater than 50000 and name is not equal to ganesh but the below query does not work out. How to use not equal to in linq and <> does not work.

(from a in dtsource.AsEnumerable where convert.ToInt32(a(“Salary”))>50000 AND a(“Name”) isnot “Ganesh” select a).CopyToDataTable

Thanks
Ula

check this :slight_smile:

https://social.msdn.microsoft.com/Forums/en-US/70186697-16e7-403d-b887-f04e92d111cc/not-equal-operator-in-linq?forum=csharplanguage

You can just use != operator as well.

1 Like

Hi @Divyashreem

Thank you but when i use != an alert comes as identify expected. Do i need to include anything?

Thanks,
Ula

@Boopathi I guess you can try this expression after and operator :
Not (a(“Name”).toString.Equals(“Ganesh”))

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.