Is there ever a reason to use Goto in modern .NET code?
        Posted  
        
            by BenAlabaster
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by BenAlabaster
        
        
        
        Published on 2010-03-30T01:25:59Z
        Indexed on 
            2010/03/30
            1:33 UTC
        
        
        Read the original article
        Hit count: 500
        
I just found this code in reflector in the .NET base libraries...
    if (this._PasswordStrengthRegularExpression != null)
    {
        this._PasswordStrengthRegularExpression = this._PasswordStrengthRegularExpression.Trim();
        if (this._PasswordStrengthRegularExpression.Length == 0)
        {
            goto Label_016C;
        }
        try
        {
            new Regex(this._PasswordStrengthRegularExpression);
            goto Label_016C;
        }
        catch (ArgumentException exception)
        {
            throw new ProviderException(exception.Message, exception);
        }
    }
    this._PasswordStrengthRegularExpression = string.Empty;
Label_016C:
    ... //Other stuff
I've heard all of the "thou shalt not use goto on fear of exile to hell for eternity" spiel. I always held MS coders in fairly high regard and while I may not have agreed with all of their decisions, I always respected their reasoning.
So - is there a good reason for code like this that I'm missing, or was this code extract just put together by a shitty developer?
I'm hoping there is a good reason, and I'm just blindly missing it.
Thanks for everyone's input
© Stack Overflow or respective owner