Is there a difference between “!=” and “is not” in C#?

Comparison table: Operator != is not Original purpose Value inequality Negated pattern matching Can perform value inequality Yes Yes Can perform negated pattern matching No Yes Can invoke implicit operator on left-hand operand Yes No Can invoke implicit operator on right-hand operand(s) Yes Yes1 Is its own operator Yes No2 Overloadable Yes No Since C# … Read more

if statements matching multiple values

How about: if (new[] {1, 2}.Contains(value)) It’s a hack though πŸ™‚ Or if you don’t mind creating your own extension method, you can create the following: public static bool In<T>(this T obj, params T[] args) { return args.Contains(obj); } And you can use it like this: if (1.In(1, 2)) πŸ™‚

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)