user3329903
user3329903

Reputation: 21

Exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll

Why get an error A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll

code:

if (wynik[rozmiarMacierzy] == 0)
{
     for (int t = 0; t < rozmiarMacierzy; t++)
     {
            appendText(wynikiTextBox, wynik[t].ToString() + "\n");
     }
}

and

private void appendText(RichTextBox textBox, string text)
{
    textBox.Invoke(new MethodInvoker(delegate { textBox.Text += text; }));
}

Upvotes: 0

Views: 2441

Answers (1)

Damith
Damith

Reputation: 63065

add wynik.Length >rozmiarMacierzy condition like below

if (wynik.Length >rozmiarMacierzy &&  wynik[rozmiarMacierzy] == 0)
{
     for (int t = 0; t < rozmiarMacierzy; t++)
     {
            if( wynik[t]!=null)
              appendText(wynikiTextBox, wynik[t].ToString() + "\n");
     }
}

Upvotes: 0

Related Questions