Code with undefined behavior in C#

后端 未结 7 740
面向向阳花
面向向阳花 2020-12-03 06:47

In C++ there are a lot of ways that you can write code that compiles, but yields undefined behavior (Wikipedia). Is there something similar in C#? Can we write code in C# th

7条回答
  •  天命终不由人
    2020-12-03 06:56

    According to the ECMA-334 document (p. 473):

    A program that does not contain any occurrences of the unsafe modifier cannot exhibit any undefined behavior.

    That promotes 'implementation-defined' to the worst case, see Eric Lippert's answer.

提交回复
热议问题