且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将对象从数据读取器转换为布尔值?

更新时间:2023-01-07 23:12:44

check Boolean.TryParse Method(String,Boolean)(System) [ ^ ]

check Boolean.TryParse Method (String, Boolean) (System)[^]
bool isActive = false;
          if (bool.TryParse(rdr["Is_Active"] + "", out isActive)) {
              emp.IsActive = isActive
          }
          else
          {
             // show the error message to the user
          }