C# Casting a List as List

前端 未结 11 1582
小鲜肉
小鲜肉 2020-12-09 15:35

Why can I not cast a List as List? Why does the following not work:

internal class ObjBase
   {
   }

int         


        
11条回答
  •  不知归路
    2020-12-09 15:56

    This is a major pain in C# - this is how generics were designed. List doesn't extend List, its just a completely different type. You can't cast or assign them to each other in any way, your only option is to copy one list to the other one.

提交回复
热议问题