blog.jj5.net (2003 to 2005)

More on SQL Types..

Sat Jan 31 09:37:00 UTC+1100 2004

Categories:

This is interesting:

      SqlBoolean a = new SqlBoolean(true);
      SqlBoolean b = new SqlBoolean(false);
      SqlBoolean c = SqlBoolean.Null;
      Console.WriteLine(a); // True
      Console.WriteLine(b); // False
      Console.WriteLine(c); // Null
      Console.WriteLine((bool)a); // True
      Console.WriteLine((bool)b); // False
      if (c) {
        Console.WriteLine("if evaluates SqlBoolean.Null = true");
      }
      else {
        Console.WriteLine("if evaluates SqlBoolean.Null = false"); // this prints
      }
      Console.WriteLine((bool)c); // exception: SqlNullValueException

John.


Copyright © 2003-2005 John Elliot