Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2015
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5. public class CarList : MonoBehaviour
  6. {
  7. public List<CarInfo> Cars;
  8.  
  9. public CarInfo this[string id]
  10. {
  11. get
  12. {
  13. return Cars.Find(a => a.Id == id);
  14. }
  15.  
  16. set
  17. {
  18. int index = Cars.FindIndex(a => a.Id == id);
  19. Cars[index] = value;
  20. }
  21. }
  22.  
  23. public CarInfo this[int index]
  24. {
  25. get
  26. {
  27. return Cars[index];
  28. }
  29. set
  30. {
  31. Cars[index] = value;
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement