1

I have this code for searching the first value and I don't know how to use index to delete specific line in the ArrayList nabídka. It should be in other method, or how to add index to return?

public string vyhledavaniOS()
        {
                foreach (Vozidlo voz in nabídka)
                {
                    if (voz is OsobníVůz)
                        return (voz.TypVozidla() + ": SPZ: " + voz.JakaSPZ + ", Značka: " + voz.JakaZnacka + ", Barva: " + voz.JakaBarva);
                }
        }
5
  • Is this you're looking for arraylist.RemoveAt() Commented Oct 21, 2013 at 6:28
  • Yes, but I don't know how to find the position of the value. Commented Oct 21, 2013 at 6:29
  • arralyList.IndexOf. but I'll suggest you to use Remove instead of using RemoveAt to make sure you're removing the correct object Commented Oct 21, 2013 at 6:30
  • and I strongly recommend you to use List<T> over ArrayList Commented Oct 21, 2013 at 6:32
  • Ok, that works, this is the last project with ArrayList, next time I will use List<T>. Commented Oct 21, 2013 at 6:36

1 Answer 1

1

This:

nabídka.RemoveAt(nabídka.IndexOf(value));

or

nabídka.Remove(object);

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.