How to print an array of strings using foreach reverse loop in C#

2 Answers

0 votes
using System;
using System.Linq;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] arr = { "c#", "c", "c++", "java", "python" };

            foreach (string s in arr.Reverse())
            {
                Console.WriteLine(s);
            }
        }
    }
}


/*
run:
    
python
java
c++
c
c#
  
*/

 



answered Feb 10, 2017 by avibootz
0 votes
using System;
using System.Linq;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] arr = { "c#", "c", "c++", "java", "python" };

            foreach (string s in arr.Reverse<string>())
            {
                Console.WriteLine(s);
            }
        }
    }
}


/*
run:
    
python
java
c++
c
c#
  
*/

 



answered Feb 10, 2017 by avibootz

Related questions

2 answers 256 views
1 answer 203 views
1 answer 223 views
1 answer 183 views
1 answer 189 views
2 answers 283 views
1 answer 169 views
...