Is there ever a reason to use goto in modern .NET code?

前端 未结 19 1676
野性不改
野性不改 2020-12-08 14:19

I just found this code in reflector in the .NET base libraries...

    if (this._PasswordStrengthRegularExpression != null)
    {
        this._PasswordStreng         


        
19条回答
  •  一生所求
    2020-12-08 14:39

    Thou shalt not look at reflector code.

    Although if you ever look at disassembled IL, you'll see gotos all over the place. In essence, all of the loops and other control constructs we use are converted to gotos anyway, it's just that by turning them into constructs in our code, it becomes more readable and easier to maintain.

    I don't think the code you posted would be a good place to use goto, by the way, and I struggle to think of one.

提交回复
热议问题