- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# Program to find the largest element from an array using Lambda Expressions
Declare an array −
int[] arr = { 10, 90, 20, 19, 99, 57 };
Now to get the largest element from an array, use Max() method with lambda expressions −
arr.Max());
Here is the complete code −
Example
using System; using System.Linq; class Demo { static void Main() { int[] arr = { 10, 90, 20, 19, 99, 57 }; Console.WriteLine(arr.Max(element => Math.Abs(element))); } }
Output
99
Advertisements