如何将List
转换为List<T>
?
var memberCommunicationPreferenceses = new PersonifyCollection<MemberCommunicationPreferences>();
memberCommunicationPreferenceses = (from ICustomerOptIn customerOptIn in customerData.CustomerOptIns
select new Models.MemberCommunicationPreferences()
{
MemberCommunicationsPrefernceId = customerOptIn.CustomerOptInId.ToString(CultureInfo.InvariantCulture),
ShortName = customerOptIn.OptionShortNameString,
ShortNameDescription = customerOptIn.OptionShortName.Description
.....
}).Where(x=>x.OptedInFlag).ToList();
Error 23 Cannot implicitly convert type 'System.Collections.Generic.List<EBusiness.Model.Models.MemberCommunicationPreferences>'
to 'EBusiness.Model.Models.Collections.PersonifyCollection<.EBusiness.Model.
Models.MemberCommunicationPreferences>' C:\\Trunk\Source\EBusiness\EBusiness.Model\Concrete\Personify\
PersonifyMemberCommunicationPreferences.cs 94 31 EBusiness.Model
更新
-
中的第二个答案的PersonifyCollection代码答案 0 :(得分:0)
我们不知道您的PersonifyCollection
课程有哪些方法,因此我们无法告诉您如何转换为该方法,或者是否有任何方法可以这样做。你可以尝试:
var something=new PersonifyCollection<MemberCommunicationPreferences>(memberCommunicationPreferences);
如果你的自定义集合实现了采用IEnumerable的标准构造函数,那么它应该可以工作。