C# Compiler thinks these variables should be initialized -
here sample of application i'm writing:
bool x3k = false, y3k = false; // of these functions homecoming nullable ints (int?) var comparing = dosomething(x, y) ?? dosomething2(x, y) ?? dosomething3(x, y, out x3k, out y3k) ?? dosomething4(x, y) ?? dosomething5(x, y); if (comparison.hasvalue) homecoming comparison.value; if (x3k) // compiler error here if don't init x3k { }
i don't understand, in null coalescing chain, how x3k uninitialized if comparison
null
, don't homecoming early. what's going on here?
you encountering short-circuit behavior: if dosomething
or dosomething2
homecoming non-null, dosomething3
never execute, leaving x3k
, y3k
uninitialized.
c#
No comments:
Post a Comment