question archive Declare the following arrays in your main method char[] letters = "the quick brown fox jumps over the lazy dog"

Declare the following arrays in your main method char[] letters = "the quick brown fox jumps over the lazy dog"

Subject:Computer SciencePrice:3.86 Bought5

Declare the following arrays in your main method

char[] letters = "the quick brown fox jumps over the lazy dog".ToCharArray();

int[] numbers = {0, 2, 3, 5, 7, 1, 1, 2, 5, 6, 7, 2, 5, 2};

string[] poem = "mary had a little lamb its fleece was white as snow".Split();

  

1.   Try to practice your foreach loop

Write method that takes an argument (an int array) and print each item on a single line separated by a space. From your main, call this method with numbers as argument2.      

 

2.Try to practice your foreach loop

Write method that takes an argument (a string array) and print each item on a single line separated by a space. From your main, call this method with poem as argument3.      

 

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Answer Preview

using System;


class MainClass {


  static void MyMethod1(int[] a) 
  {
    for (int i = 0; i < a.Length; i++) 
    {
      Console.Write(a[i]+" ");
    }
  }


  static void MyMethod2(string[] a) 
  {
    for (int i = 0; i < a.Length; i++) 
    {
      Console.Write(a[i]+" ");
    }
  }


  public static void Main (string[] args) {
    char[] letters = "the quick brown fox jumps over the lazy dog".ToCharArray();


    int[] numbers = {0, 2, 3, 5, 7, 1, 1, 2, 5, 6, 7, 2, 5, 2};


    string[] poem = "mary had a little lamb its fleece was white as snow".Split();


    MyMethod1(numbers);
    Console.WriteLine();
    MyMethod2(poem);


  }
}

Please see the attached file for the complete solution