SEHException .NET难题

编程入门 行业动态 更新时间:2024-10-05 13:24:41
本文介绍了SEHException .NET难题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

任何人都可以解释为什么低于code抛出一个错误。它可以很容易地固定或者-1值转换为一十进制(-1M),通过改变运算符重载接受一个int或不使用一个可为空的对象。

我注意到犯规在VS2010 VS2008只是抛出的错误。

类节目 {     静态无效的主要(字串[] args)     {         VAR 01 =新的MyObject(新MyObject来(2.34M))?;         O1 * = -1;     } } 公共结构为MyObject {     公众为MyObject(十进制myvalue的)     {         this.myValue = myvalue的;     }     私人十进制myvalue的;     公共静态为MyObject符*(myObject的值1,十进制值2)     {         value1.myValue * =值;         返回值1;     } }

解决方案

没有摄制与给定的code段。您所使用的code但是非常类似于落在了一个旧的错误,在C#编译器的那种code。细节是在this螺纹,埃里克利珀已经意识到这一点。

Can anyone explain why the below code throws an error. It can easily be fixed by either casting the -1 value to a decimal (-1M), by changing the operator overload to accept an int or by not using a nullable object.

I have noticed the error doesnt get thrown in VS2010 only VS2008.

class Program { static void Main(string[] args) { var o1 = new MyObject?(new MyObject(2.34M)); o1 *= -1; } } public struct MyObject { public MyObject(Decimal myValue) { this.myValue = myValue; } private Decimal myValue; public static MyObject operator *(MyObject value1, decimal value2) { value1.myValue *= value2; return value1; } }

解决方案

No repro with the given code snippet. The code you used however strongly resembles the kind of code that falls over on an old bug in the C# compiler. The details are in this thread, Eric Lippert is already aware of it.

更多推荐

SEHException .NET难题

本文发布于:2023-11-29 15:17:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1646772.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:难题   SEHException   NET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!