Quang Dinh Luong

Quang Dinh Luong

  • NA
  • 76
  • 17.8k

Cannot apply indexing with [] to an expression of type "int"

Oct 9 2015 10:17 PM
int n = int.Parse(textBox2.Text);
int Primes[n + 1];
for (int i = 0; i <= Sqrt(n); i++)
       Primes[i] = 1;
Primes[0] = 0;
Primes[1] = 0;
for(int i = 2; i <= n; i++)
{
     if(Primes[i] == 1)
     {
         for (int j = 2; i * j <= n; j++)
         Primes[i * j] = 0;
     }
}
 The error is the subject!
I marked error code as red! 
Is anyone know why?
Thanks 

Answers (5)