Нужны объяснения к коду operator * - C#

Узнай цену своей работы

Формулировка задачи:

Листинг программы
  1. using System;
  2. class Program
  3. {
  4. static void Main(string[] args)
  5. {
  6. MyArray array = new MyArray(new int[] { 1, 2, 3, 4, 5 });
  7. MyArray array2 = new MyArray(new int[] { 6, 7, 8, 9, 10, 11, 12 });
  8. Console.WriteLine(array * array2);
  9. Console.ReadKey();
  10. }
  11. }
  12. class MyArray
  13. {
  14. int[] array;
  15. public int Length {get; private set;}
  16. public MyArray() { }
  17. public MyArray(int size)
  18. {
  19. Length = size;
  20. array = new int[size];
  21. array.Initialize();
  22. }
  23. public MyArray(params int[] elements) : this(elements.Length)
  24. {
  25. Array.Copy(elements, array, elements.Length);
  26. }
  27. public int this[int index]
  28. {
  29. get
  30. {
  31. return array[index];
  32. }
  33. set
  34. {
  35. array[index] = value;
  36. }
  37. }
  38. public static int? operator *(MyArray a1, MyArray a2)
  39. {
  40. int? mul = null;
  41. for (int i = 0; i < a1.Length; i++)
  42. if (a1[i] % 2 == 0)
  43. mul = mul == null ? a1[i] : mul * a1[i];
  44. for (int i = 0; i < a2.Length; i++)
  45. if (a2[i] % 2 == 0)
  46. mul = mul == null ? a2[i] : mul * a2[i];
  47. return mul;
  48. }
  49. }

Решение задачи: «Нужны объяснения к коду operator *»

textual
Листинг программы
  1. array * array2

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

15   голосов , оценка 3.933 из 5

Нужна аналогичная работа?

Оформи быстрый заказ и узнай стоимость

Бесплатно
Оформите заказ и авторы начнут откликаться уже через 10 минут