Cast received object to a List<object> or IEnumerable<object>

后端 未结 8 1570
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-07 23:52

I\'m trying to perform the following cast

private void MyMethod(object myObject)  
{  
    if(myObject is IEnumerable)  
    {
        List c         


        
      
      
      
8条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-08 00:33

    How about

    List collection = new List((IEnumerable)myObject);
    
        

    提交回复
    热议问题