1.  
  2. using System;
  3.  
  4. class ArrayExample
  5. {
  6. static void DisplayArray(string[] arr) => Console.WriteLine(string.Join(" ", arr));
  7.  
  8. // Change the array by reversing its elements.
  9. static void ChangeArray(string[] arr) => Array.Reverse(arr);
  10.  
  11. static void ChangeArrayElements(string[] arr)
  12. {
  13. // Change the value of the first three array elements.
  14. arr[0] = "Mon";
  15. arr[1] = "Wed";
  16. arr[2] = "Fri";
  17. }
  18.  
  19. static void Main()
  20. {
  21. // Declare and initialize an array.
  22. string[] weekDays = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
  23. // Display the array elements.
  24. DisplayArray(weekDays);
  25. Console.WriteLine();
  26.  
  27. // Reverse the array.
  28. ChangeArray(weekDays);
  29. // Display the array again to verify that it stays reversed.
  30. Console.WriteLine("Array weekDays after the call to ChangeArray:");
  31. DisplayArray(weekDays);
  32. Console.WriteLine();
  33.  
  34. // Assign new values to individual array elements.
  35. ChangeArrayElements(weekDays);
  36. // Display the array again to verify that it has changed.
  37. Console.WriteLine("Array weekDays after the call to ChangeArrayElements:");
  38. DisplayArray(weekDays);
  39. }
  40. }
  41. // The example displays the following output:
  42. // Sun Mon Tue Wed Thu Fri Sat
  43. //
  44. // Array weekDays after the call to ChangeArray:
  45. // Sat Fri Thu Wed Tue Mon Sun
  46. //
  47. // Array weekDays after the call to ChangeArrayElements:
  48. // Mon Wed Fri Wed Tue Mon Sun
  49.