![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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# Queryable Max Method
Get the maximum value from a sequence using the Max() method.
Let’s say the following is our list.
List<long> list = new List<long> { 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000 };
Use the Max() method to get the largest element.
list.AsQueryable().Max();
Example
using System; using System.Collections.Generic; using System.Linq; class Demo { static void Main() { List<long> list = new List<long> { 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000 }; foreach(long ele in list) Console.WriteLine(ele); // getting largest element long max_num = list.AsQueryable().Max(); Console.WriteLine("Largest number = {0}", max_num); } }
Output
200 400 600 800 1000 1200 1400 1600 1800 2000 Largest number = 2000
Advertisements