0

While working on a .Net project and SqlDataReader, came to question about difference between:

Convert.ToBoolean(reader["Name"])

And:

(bool) (reader["Name"])
DavidG
  • 113,891
  • 12
  • 217
  • 223
Sami
  • 3,686
  • 4
  • 17
  • 28
  • 3
    The first will work if `Name` is a `string` with the value of `true`. The latter won't (it will only work if `Name` is actually a `bool`). – mjwills Jun 28 '18 at 00:10
  • 2
    The first is called _Conversion_. The second is called _Casting_. – kurakura88 Jun 28 '18 at 01:13
  • [`Convert.ToBoolean(/* a bunch of overloads, one accepts string, another object */)`](https://msdn.microsoft.com/en-us/library/system.convert.toboolean(v=vs.110).aspx). – user2864740 Jun 28 '18 at 01:16

0 Answers0