转换的IList< T>到的BindingList< T> [英] Convert IList<T> to BindingList<T>

查看:199
本文介绍了转换的IList< T>到的BindingList< T>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的C#程序,我有一个返回的IList℃的方法;客户> 名单,我怎么可以把它转换为的BindingList<客户> ?


解决方案

  VAR yourList =新的List<客户> (); 
变种listBinding =新的BindingList<客户>(yourList);

的BindingList构造



您不需要做演员,只需要提供的BindingList< T> 类的构造函数与的IList< T> ,你有


In my c# program, I have a method that return an IList<Customer> list, how can I cast it to BindingList<Customer> ?

解决方案

var yourList = new List<Customer>();
var listBinding = new BindingList<Customer>(yourList);

BindingList Constructors

You don't need to do a cast, just provide the BindingList<T> class constructor with IList<T>, which you have.

这篇关于转换的IList&LT; T&GT;到的BindingList&LT; T&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆