Advertisement
punidota

Untitled

Mar 4th, 2016
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. class ListIndexer
  2. {
  3. string[] arr;
  4. public int Length;
  5. public ListIndexer(int Size)
  6. {
  7. arr = new string[Size];
  8. Length = Size;
  9. }
  10. public string this[int index]
  11. {
  12. set { arr[index] = value; }
  13. get { return arr[index]; }
  14. }
  15. }
  16. private void search_Click(object sender, EventArgs e)
  17. {
  18. var list = new ListIndexer(Size: lbCollection.Items.Count);
  19. for (int i = 0; i < list.Length; i++)
  20. {
  21. list[i] = lbCollection.Items[i].ToString();
  22. }
  23. MessageBox.Show("Элемент под индексом " + (Convert.ToInt32(index.Text)) + " = " + list[Convert.ToInt32(index.Text)].ToString());
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement