C# convert bit to boolean

后端 未结 5 1603
北恋
北恋 2021-01-01 10:32

I have a Microsoft SQL Server database that contains a data field of BIT type.

This field will have either 0 or 1 values to re

5条回答
  •  庸人自扰
    2021-01-01 11:10

    How are you extracting the fields from the database?

    The SqlDataReader class has a GetBoolean method which does the translation for you:

    bool yourBoolean = reader.GetBoolean(reader.GetOrdinal("Your_Bit_Column"));
    

提交回复
热议问题