D
D
Dmitry Gavrilenko2015-12-25 16:53:01
.NET
Dmitry Gavrilenko, 2015-12-25 16:53:01

System.Collection.Generic.List does not contain a definition for "Max" WAT???

Bullshit, bullshit and more bullshit!!!
I have a bomb.
There is a method returning List.

List<Appartament> objs = GetObjects();
if(objs.Count() > 0)
{
    floors = objs.Max(y => y.Floor);
}

Works great!
Just below
List<Appartament> objs = GetObjects(Buildings[index]);
floors = objs.Max(y => y.Floor);

error CS1977: Cannot use a lambda expression as an argument to a dynamically dispatched operation without first converting it to a delegate or an expression
tree . But I don't have dynamic . OK. I do the following:
floors = objs.Max("Floor");
I get:
"System.Collections.Generic.List" does not contain a definition for "Max"
UPD:
Problem solved:
for(int i = 0; i < obj.Count; i++)
{
    if(objs[i].Floor > floors)
    {
        floors = objs[i].Floor;
    }
    if(objs[i].Section > sections)
    {
        sections = objs[i].Section;
    }
}

But the question remains!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Kovalsky, 2015-12-25
@dmitryKovalskiy

using System.Linq is there?

M
MonkAlex, 2015-12-25
@MonkAlex

stackoverflow.com/questions/29754042/cannot-use-a-...
Advise to parse field value for speakers.
What do you have - figure it out yourself, but the error is typical.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question