What exception to throw from a property setter?

后端 未结 7 2103
醉话见心
醉话见心 2020-12-08 02:24

I have a string property that has a maximum length requirement because the data is linked to a database. What exception should I throw if the caller tries to set a string ex

7条回答
  •  北海茫月
    2020-12-08 02:55

    You may use InvalidOperationException. That's a compromise. I wouldn't bother using an ArgumentException either.

提交回复
热议问题