Errore Index e length devono fare riferimento a una posizione nella stringa.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rciorra
    New Member
    • Jun 2015
    • 1

    Errore Index e length devono fare riferimento a una posizione nella stringa.

    Hi, i have this message
    Index e length devono fare riferimento a una posizione nella stringa.
    Nome parametro: length
    i don't know because the code after "else" generates the error.

    Code:
    imponibile = System.Math.Round((totale / (1 + (iva / 100))), 2, MidpointRounding.ToEven);
            String res2 = "" + imponibile;
            String[] arres2 = res2.Split(',');
            if (arres2.Length > 1)
            {
                res2 = arres2[0] + ",";
                String dec = arres2[1];
                if (dec.Length >= 2)
                    res2 += dec.Substring(0, 2);
                else
                    res2 += dec.Substring(0, 2);
    
            }
            TextBoxMImponibile.Text = res2;
    Last edited by Rabbit; Jun 23 '15, 11:14 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • computerfox
    Contributor
    • Mar 2010
    • 276

    #2
    Looks like the error is in Spanish.

    I would suggest starting with adding the brackets for the conditional statements, I believe there are newlines before the statement plus its standard practice to do so.

    For debugging, print dec prior to the if statement.

    Comment

    Working...