Cannot convert HashSet to IReadOnlyCollection

前端 未结 2 432
故里飘歌
故里飘歌 2021-01-17 10:56

I have a HashSet and I am trying to cast it into IReadOnlyCollection, but I am getting error:

Cannot implicitly convert type \'System.Collections.Gene

2条回答
  •  我在风中等你
    2021-01-17 11:38

    You're using 4.5 and Hashset doesn't implement IReadOnlyCollection until 4.6

    From MSDN:

    HashSet implements the IReadOnlyCollection interface starting with the .NET Framework 4.6; in previous versions of the .NET Framework, the HashSet class did not implement this interface.

    https://msdn.microsoft.com/en-us/library/bb359438(v=vs.110).aspx

提交回复
热议问题