
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Find Smallest Element from Array Using Lambda Expressions in C#
Declare an array −
int[] arr = { 10, 15, 5, 20};
Now to get the smallest element from an array, use Min() method with lambda expressions −
arr.Min());
Here is the complete code −
Example
using System; using System.Linq; class Demo { static void Main() { int[] arr = { 10, 15, 5, 20}; Console.WriteLine(arr.Min(element => Math.Abs(element))); } }
Output
5
Advertisements