Browse by Tags

Tagged Content List
  • 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: Foolish consistency is foolish

    Once again today's posting is presented as a dialogue, as is my wont. Why is var sometimes required on an implicitly-typed local variable and sometimes illegal on an implicitly typed local variable? That's a good question but can you make it more precise? Start by listing the situations in which an implicitly...
  • Blog Post: What is the defining characteristic of a local variable?

    If you ask a dozen C# developers what a "local variable" is, you might get a dozen different answers. A common answer is of course that a local is "a storage location on the stack". But that is describing a local in terms of its implementation details; there is nothing in the C# language that requires...
  • Blog Post: Simple names are not so simple

    C# has many rules that are designed to prevent some common sources of bugs and encourage good programming practices. So many, in fact, that it is often quite confusing to sort out exactly which rule has been violated. I thought I might spend some time talking about what the different rules are. We'll...
  • Blog Post: What's The Difference, Part Two: Scope vs Declaration Space vs Lifetime

    "Scope" has got to be one of the most confusing words in all of programming language design. People seem to use it casually to mean whatever is convenient at the time; I most often see it confused with lifetime and declaration space . As in "the memory will be released when the variable goes out of scope...
Page 1 of 1 (5 items)