Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c#: shorter way to write v1! ? v2 : !v2

Tags:

syntax

c#

boolean

Can I write

bool v1, v2;
// ...

EDIT: I am very sorry for the confusions. The correct statement should be:

bool v3 = !v1 ? v2 : !v2;

ORIGINAL I asked for

bool v3 = v1 ? v2 : !v2;

even shorter? Or: Is there an operator which will have the same result?

So I marked Anders Abels answer as correct, because he answered my initial question. I only need to invert his answer.

like image 382
Daniel Bişar Avatar asked Dec 04 '22 06:12

Daniel Bişar


1 Answers

I think v1==v2 should do it.

Edit:

For the updated question, it's v1!=v2, or v1^v2 as Anders said.

like image 128
Vlad Avatar answered Dec 11 '22 20:12

Vlad