Files
codeql/csharp/ql/test/library-tests/controlflow/graph/NullCoalescing.cs
2018-08-06 13:45:23 -07:00

20 lines
407 B
C#

class NullCoalescing
{
int M1(int? i) => i ?? 0;
int M2(bool? b) => (b ?? false) ? 0 : 1;
string M3(string s1, string s2) => s1 ?? s2 ?? "";
string M4(bool b, string s) => (b ? s : s) ?? "" ?? "";
int M5(bool? b1, bool b2, bool b3) => (b1 ?? (b2 && b3)) ? 0 : 1;
void M6(int i)
{
var j = (int?)null ?? 0;
var s = "" ?? "a";
j = (int?)i ?? 1;
}
}