Error: Can't convert from Dictionary to IDictionary

前端 未结 1 908
栀梦
栀梦 2021-01-15 02:54

Why is there an error Error 52 Argument 1: cannot convert from \'System.Collections.Generic.Dictionary>\' to \'System.Collections.Generic.IDictionary>\'

         


        
相关标签:
1条回答
  • 2021-01-15 03:06

    Dictionary<string, List<string>> implements IDictionary<string, List<string>>, while you're trying to cast it to IDictionary<string, *I*List<string>>. It is not allowed, because IDictionary<string, IList<string>> has e.g. the method Add accepting instance of IList<string>, while Add method in your Dictionary<string, List<string>> won't accept IList<string> as its input.

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