Checking if a datatable is null

后端 未结 7 1853
南旧
南旧 2021-02-19 22:02

The following code is what I\'ve been using to retrieve user information from a sql database.

            string userName = LoginUser.UserName;
            strin         


        
7条回答
  •  失恋的感觉
    2021-02-19 22:21

    I know this question IS OLD and the answers helped at the moment it was published, but there is an easy way to solve this right now as follows:

    if ((dataTableName?.Rows?.Count ?? 0) > 0)
    

提交回复
热议问题