Tech Off Post

Single Post Permalink

View Thread: null + null = ?
  • User profile image

    Londoner wrote:
    Here is another one for you:

    class Class1
          public int c = true;  // <---- It compiles!!
          public Class1(): this(0) {}
          public Class1(int i): this() {} 
          static void Main(string[] args)

    It compiles because there is no syntax error, and the compiler can make code for it, just as it does for this:

    public void First()

    public void Second()

    It's no different. The compiler isn't fooled, it is doing exactly what you told it to do.