因为int和string之间没有隐式转换

因为int和string之间没有隐式转换

本文介绍了无法确定条件表达式的类型,因为int和string之间没有隐式转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是代码,我有大胆的和平错误:



 var isIdSortable = Convert.ToBoolean(Request [bSortable_1 ]); 

var isNameSortable = Convert.ToBoolean(Request [bSortable_2]);
var isAddressSortable = Convert.ToBoolean(Request [bSortable_3]);
var isTownSortable = Convert.ToBoolean(Request [bSortable_4]);

var sortColumnIndex = Convert.ToInt32(Request [iSortCol_0]);
Func< Order,string> orderingFunction =(c => sortColumnIndex == 1&& isIdSortable?c.OrderID:
sortColumnIndex == 2&& isNameSortable?c.CustomerID:
sortColumnIndex == 3 && isAddressSortable?c.ShipAddress:
sortColumnIndex == 4&& isTownSortable?c.ShipCountry:
);







OrderID是INT,CustomerID地址和国家是字符串



我尝试了什么:



i刚刚在

解决方案



This is the code and i have error to the bold peace :

var isIdSortable = Convert.ToBoolean(Request["bSortable_1"]);

           var isNameSortable = Convert.ToBoolean(Request["bSortable_2"]);
           var isAddressSortable = Convert.ToBoolean(Request["bSortable_3"]);
           var isTownSortable = Convert.ToBoolean(Request["bSortable_4"]);

           var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]);
           Func<Order, string> orderingFunction = (c =>  sortColumnIndex == 1 && isIdSortable ? c.OrderID :
             sortColumnIndex == 2 && isNameSortable ? c.CustomerID :
                                                          sortColumnIndex == 3 && isAddressSortable ? c.ShipAddress :
                                                          sortColumnIndex == 4 && isTownSortable ? c.ShipCountry :
                                                          "");




OrderID is INT , CustomerID Adress and Country are string

What I have tried:

i just explained the problem above in the section

解决方案



这篇关于无法确定条件表达式的类型,因为int和string之间没有隐式转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 05:41