Cannot apply indexing with [] to an expression of type 'System.Collections.Generic.ICollection in mvc controller

前端 未结 3 793
悲哀的现实
悲哀的现实 2021-02-19 00:10
public ActionResult addstandardpackage1(ICollection SingleStay,ICollection DOUBLESTAY,ICollection TRIBLESTAY,ICollection FAMI         


        
3条回答
  •  终归单人心
    2021-02-19 00:39

    ICollection doesn't expose indexer. You have three options:

    1. Change ICollection to IList
    2. Use ElementAt that is inherited from IEnumerable. But be aware - it could not be efficient.
    3. Evalute passed collection to list (ToList())

    ICollection (and its exposed methods) on msdn.

提交回复
热议问题