code-analyst

IndexOutOfRangeException in indexed getter

こ雲淡風輕ζ 提交于 2019-12-10 13:53:37
问题 In my indexed property I check whether the index is out of bounds or not. If it is, I throw an IndexOutOfBoundsException . When I run the Code Analyst (in VS12) it complains with CA1065: Unexpected exception in unexpected location. Referring to the description of CA1065, only System.InvalidOperationException System.NotSupportedException System.ArgumentException KeyNotFoundException are allowed in an indexed getter. Throwing IndexOutOfBoundsException seems natural to me, so what is the