C#相当于Python中的“值错误”

时间:2021-08-13 16:49:49

Is there a C# error exception for a value error? the equivalent of the python "value error" below?

是否存在值错误的C#错误异常?相当于下面的python“值错误”?

    except ValueError as e:

1 个解决方案

#1


12  

Sounds like you probably want ArgumentException, or ArgumentNullException, or ArgumentOutOfRangeException depending on the precise nature. (The latter exceptions are subtypes of the first.)

听起来你可能想要ArgumentException,或ArgumentNullException,或ArgumentOutOfRangeException,具体取决于确切的性质。 (后者的例外是第一个的子类型。)

#1


12  

Sounds like you probably want ArgumentException, or ArgumentNullException, or ArgumentOutOfRangeException depending on the precise nature. (The latter exceptions are subtypes of the first.)

听起来你可能想要ArgumentException,或ArgumentNullException,或ArgumentOutOfRangeException,具体取决于确切的性质。 (后者的例外是第一个的子类型。)