0

I have to convert some code from Java to C#, and I don't know what the equivalent is of Arraylist.get(index) from Java in .NET C#.

I want to convert something like this:

for (int i=0;i<M+1;i++)
    if(SF.get(i) == SC.get(i))
        ok= true;
    else ok=false;
Don't Panic
  • 41,125
  • 10
  • 61
  • 80
Caruso
  • 3
  • 1
  • 2

2 Answers2

1
for (int i = 0; i < M + 1; i++)
{
    if (SF[i] == SC[i])
        ok = true;

    else
        ok = false;
}
tonybasran
  • 112
  • 4
0

Checkout the item property provided by the overloaded "[]" operator. MSDN => https://msdn.microsoft.com/en-us/library/0ebtbkkc(v=vs.110).aspx List.Item Property (Int32)

For example:

var value  = SC[index]
aeje
  • 239
  • 1
  • 9
  • The correct term for that `[]` is **indexer** in C# and **Default Property** in VB.NET. https://msdn.microsoft.com/library/6x16t2tx.aspx – Crusha K. Rool Oct 18 '16 at 19:54