Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
C# Linq Reverse Method
Reverse the elements in an array, using the Reverse method.
Here is our character array.
char[] ch = { 't', 'i', 'm', 'e' };
Now use the Reverse() method with AsQueryable() method to get the reverse.
ch.AsQueryable().Reverse();
Let us see the complete code.
Example
using System;
using System.Linq;
using System.Collections.Generic;
public class Demo {
public static void Main() {
char[] ch = { 't', 'i', 'm', 'e' };
Console.Write("String = ");
foreach(char arr in ch) {
Console.Write(arr);
}
IQueryable<char> res = ch.AsQueryable().Reverse();
Console.Write("\nReversed String = ");
foreach (char c in res) {
Console.Write(c);
}
}
}
Output
String = time Reversed String = emit
Advertisements
