I have a column named source of type bit in my database. but I want to get set its value in my program. how can I do that? I know it was a simple doubt but I was li开发者_StackOverflow中文版ttle bit confused. Do I have to use byte as type while setting this or not?
Use bool for representation bit from database:
public bool MyBitDbProperty {get;set;}
If you use SqlDataReader than use reader.GetBoolean(position) for bit type.
If you use any rdbms(like linq to sql), bit will mapped to bool by default.
The bit database type will contain the values 0 and 1, and normally (you've not stated RDMS) corresponds nicely with the bool or Boolean types in c#.
精彩评论