Cannot implicitly convert List to Collection

后端 未结 7 2098
悲哀的现实
悲哀的现实 2020-12-08 13:44

This is a compiler error (slightly changed for readability).

This one always puzzled me. FxCop tells that this is a bad thing to return List and classes that are\\de

相关标签:
7条回答
  • 2020-12-08 14:14

    Why not just do the following:

    Collection<string> collection = new Collection<string>(theList);
    

    as Collection(IList input) takes a List as part of construction.

    0 讨论(0)
提交回复
热议问题