Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

linq select max value from list

var item = items.MaxBy(x => x.Height);
Comment

how to get max value in list from linq c#

private void Test()
{
    test v1 = new test();
    v1.Id = 12;

    test v2 = new test();
    v2.Id = 12;

    test v3 = new test();
    v3.Id = 12;

    List<test> arr = new List<test>();
    arr.Add(v1);
    arr.Add(v2);
    arr.Add(v3);

    test max = arr.OrderByDescending(t => t.Id).First();
}

class test
{
    public int Id { get; set; }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: interop C# save as and replace 
Csharp :: change color unity over time 
Csharp :: devexpress spreadsheet document source wpf 
Csharp :: serialize xml as array C# 
Csharp :: Merge two List using Linq 
Csharp :: unity gun clipping through walls 
Csharp :: how to fade c# form 
Csharp :: c# progress bar timer 
Csharp :: access label from another class c# 
Csharp :: cant find desktop and documents folder macOs 
Csharp :: c# on variable change property get set 
Csharp :: c# get file author 
Csharp :: c# convert excel column index to letter 
Csharp :: c# get executing file name 
Csharp :: example of List c# 
Csharp :: cread 2-dimensional array in c# 
Csharp :: what is failure 
Csharp :: select many vs select 
Csharp :: console writeline 
Csharp :: gql query with parameters 
Csharp :: long string c# 
Csharp :: c# new object 
Csharp :: C# [] overload 
Csharp :: inheritance in c# 
Csharp :: *ngif vs ngif 
Csharp :: list contains type c# 
Csharp :: how to add object in dictionary in c# 
Csharp :: AuthenticationTicket authenticationProperties C# .net 
Csharp :: c# core linq savechanges invalid column name error while adding but not while updating 
Csharp :: singleton pattern c# stack overflow 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =