Browse by Tags

Tagged Content List
  • Blog Post: Out parameters and LINQ do not mix

    I am back from my annual vacation in beautiful southwestern Ontario; before I get into the subject of today's post, check out this shot I took with my Windows Phone camera from the plane on the trip home. We are at 37000 feet, just outside of Billings, Montana, a few minutes before sunset: The whole...
  • Blog Post: Should C# warn on null dereference?

    As you probably know, the C# compiler does flow analysis on constants for the purposes of finding unreachable code. In this method the statement with the calls is known to be unreachable, and the compiler warns about it. const object x = null; void Foo() { if (x != null) { Console.WriteLine(x.GetHashCode...
  • Blog Post: Why are local variables definitely assigned in unreachable statements?

    You're probably all familiar with the feature of C# which disallows reading from a local variable before it has been "definitely assigned": void M() { int x; if (Q()) x = 123; if (R()) Console.WriteLine(x); // illegal! } This is illegal because there is a path through the code which, if taken, results...
  • Blog Post: A Definite Assignment Anomaly

    UPDATE: I have discovered that this issue is considerably weirder than the initial bug report led me to believe. I've rewritten the examples in this article; the previous ones did not actually demonstrate the bug. Consider the following code: struct S { private string blah; public S(string blah...
  • Blog Post: Absence of evidence is not evidence of absence

    Today, two more subtly incorrect myths about C#. As you probably know, C# requires all local variables to be explicitly assigned before they are read, but assumes that all class instance field variables are initially assigned to default values. An explanation of why that is that I sometimes hear is...
Page 1 of 1 (5 items)