1
My class:
public class Carros {
public int ID { get; private set; }
public string Atributo2 { get; private set; }
public int Atributo3 { get; private set; }}}
Suppose the ID attribute could not repeat itself and I created a Collection of the type of that class and wanted to return from that Collection only the car that had ID == 2
Then I would:
var carroId2 = from carro in collectionCarros
where carro.ID == 2
select new {
Id = carro.ID
};
And I wish I could do something like carroId2.ID
to return the value of the attribute, but I can only do this within a loop ? Or is there another way I can do this.